OPNFLWPLUG-1070 17/81317/12
authornithi thomas <nithi.t@altencalsoftlabs.com>
Fri, 29 Mar 2019 11:11:06 +0000 (16:41 +0530)
committerNishchya Gupta <nishchyag@altencalsoftlabs.com>
Fri, 12 Jul 2019 11:30:17 +0000 (17:00 +0530)
OVS Based NA Responder for IPv6 default Gateway

Added support IPv6 NA responder fields as part of
odl-openflowplugin-eric-extensions feature.
As per the changes, below eric experimenter fields will be supported with
vendor ID 0X1000.
nd_reserved - OXM name: ERICOXM_OF_ICMPV6_ND_RESERVED(1)
nd_options_type - OXM name: ERICOXM_OF_ICMPV6_ND_OPTION_TYPE(2)
Yes this feature is  present in the OVS master with below patch detail.
https://github.com/openvswitch/ovs/commit/9b2b84973db76e1138d9234ff1b84bb6bb156011

Change-Id: I7e53b54097c6678046f5b216537129157081913c
Signed-off-by: nithi thomas <nithi.t@altencalsoftlabs.com>
36 files changed:
artifacts/pom.xml
extension/features-extension-aggregator/features-openflowplugin-extension/pom.xml
extension/features-extension-aggregator/odl-openflowplugin-eric-extensions/pom.xml [new file with mode: 0644]
extension/features-extension-aggregator/odl-openflowplugin-eric-extensions/src/main/features/features.xml [new file with mode: 0644]
extension/features-extension-aggregator/odl-openflowplugin-nxm-extensions/pom.xml
extension/features-extension-aggregator/pom.xml
extension/openflowjava-extension-eric/pom.xml [new file with mode: 0644]
extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/EricExtensionCodecRegistratorImpl.java [new file with mode: 0644]
extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/EricExtensionsRegistrator.java [new file with mode: 0644]
extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/api/EricConstants.java [new file with mode: 0644]
extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/api/EricExtensionCodecRegistrator.java [new file with mode: 0644]
extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/codec/match/AbstractMatchCodec.java [new file with mode: 0644]
extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/codec/match/EricHeader.java [new file with mode: 0644]
extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/codec/match/EricMatchCodecs.java [new file with mode: 0644]
extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/codec/match/Icmpv6NDOptionsTypeCodec.java [new file with mode: 0644]
extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/codec/match/Icmpv6NDReservedCodec.java [new file with mode: 0644]
extension/openflowjava-extension-eric/src/main/resources/org/opendaylight/blueprint/openflowjava-extension-eric.xml [new file with mode: 0644]
extension/openflowjava-extension-eric/src/main/yang/eric-match.yang [new file with mode: 0644]
extension/openflowjava-extension-eric/src/test/java/org/opendaylight/openflowjava/eric/EricExtensionCodecRegistratorImplTest.java [new file with mode: 0644]
extension/openflowjava-extension-eric/src/test/java/org/opendaylight/openflowjava/eric/EricExtensionsRegistratorTest.java [new file with mode: 0644]
extension/openflowjava-extension-eric/src/test/java/org/opendaylight/openflowjava/eric/codec/match/EricHeaderTest.java [new file with mode: 0644]
extension/openflowjava-extension-eric/src/test/java/org/opendaylight/openflowjava/eric/codec/match/Icmpv6NDOptionsTypeCodecTest.java [new file with mode: 0644]
extension/openflowjava-extension-eric/src/test/java/org/opendaylight/openflowjava/eric/codec/match/Icmpv6NDReservedCodecTest.java [new file with mode: 0644]
extension/openflowplugin-extension-eric/pom.xml [new file with mode: 0644]
extension/openflowplugin-extension-eric/src/main/java/org/opendaylight/openflowplugin/extension/vendor/eric/EricExtensionProvider.java [new file with mode: 0644]
extension/openflowplugin-extension-eric/src/main/java/org/opendaylight/openflowplugin/extension/vendor/eric/convertor/CodecPreconditionException.java [new file with mode: 0644]
extension/openflowplugin-extension-eric/src/main/java/org/opendaylight/openflowplugin/extension/vendor/eric/convertor/match/Icmpv6NDOptionsTypeConvertor.java [new file with mode: 0644]
extension/openflowplugin-extension-eric/src/main/java/org/opendaylight/openflowplugin/extension/vendor/eric/convertor/match/Icmpv6NDReservedConvertor.java [new file with mode: 0644]
extension/openflowplugin-extension-eric/src/main/java/org/opendaylight/openflowplugin/extension/vendor/eric/convertor/match/MatchUtil.java [new file with mode: 0644]
extension/openflowplugin-extension-eric/src/main/resources/org/opendaylight/blueprint/openflowplugin-extension-eric.xml [new file with mode: 0644]
extension/openflowplugin-extension-eric/src/main/yang/openflowplugin-extension-eric-match.yang [new file with mode: 0644]
extension/openflowplugin-extension-eric/src/test/java/org/opendaylight/openflowplugin/extension/vendor/eric/convertor/match/Icmpv6NDOptionsTypeConvertorTest.java [new file with mode: 0644]
extension/openflowplugin-extension-eric/src/test/java/org/opendaylight/openflowplugin/extension/vendor/eric/convertor/match/Icmpv6NDReservedConvertorTest.java [new file with mode: 0644]
extension/pom.xml
extension/test-extension/pom.xml
openflowjava/openflow-protocol-api/src/main/yang/openflow-extensible-match.yang

index 44e1ff0bfbc4dc4e8c6f06841d45efe2e8da483d..0cea5d09f4b2732a040ca3d57b836231003cdc99 100644 (file)
                 <artifactId>openflowplugin-extension-nicira</artifactId>
                 <version>${project.version}</version>
             </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>openflowplugin-extension-eric</artifactId>
+                <version>${project.version}</version>
+            </dependency>
             <dependency>
                 <groupId>${project.groupId}</groupId>
                 <artifactId>openflowjava-extension-nicira-api</artifactId>
                 <artifactId>openflowjava-extension-nicira</artifactId>
                 <version>${project.version}</version>
             </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>openflowjava-extension-eric</artifactId>
+                <version>${project.version}</version>
+            </dependency>
             <dependency>
                 <groupId>${project.groupId}</groupId>
                 <artifactId>openflowplugin-extension-onf</artifactId>
                 <type>xml</type>
                 <version>${project.version}</version>
             </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>odl-openflowplugin-eric-extensions</artifactId>
+                <classifier>features</classifier>
+                <type>xml</type>
+                <version>${project.version}</version>
+            </dependency>
             <dependency>
                 <groupId>${project.groupId}.openflowjava</groupId>
                 <artifactId>odl-openflowjava-protocol</artifactId>
index ca49b6355c535e8841d9d11731c9d4f9417591b3..065c991ebbaa7d2f8d14355c876bf079ad367434 100644 (file)
             <type>xml</type>
             <classifier>features</classifier>
         </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>odl-openflowplugin-eric-extensions</artifactId>
+            <version>${project.version}</version>
+            <type>xml</type>
+            <classifier>features</classifier>
+        </dependency>
     </dependencies>
 
 </project>
diff --git a/extension/features-extension-aggregator/odl-openflowplugin-eric-extensions/pom.xml b/extension/features-extension-aggregator/odl-openflowplugin-eric-extensions/pom.xml
new file mode 100644 (file)
index 0000000..9863286
--- /dev/null
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.opendaylight.odlparent</groupId>
+        <artifactId>single-feature-parent</artifactId>
+        <version>4.0.9</version>
+        <relativePath/>
+    </parent>
+
+    <groupId>org.opendaylight.openflowplugin</groupId>
+    <artifactId>odl-openflowplugin-eric-extensions</artifactId>
+    <packaging>feature</packaging>
+    <version>0.9.0-SNAPSHOT</version>
+
+    <name>OpenDaylight :: Openflow Plugin :: Eric Extensions</name>
+
+    <dependencyManagement>
+        <dependencies>
+            <!-- This project -->
+            <dependency>
+                <groupId>org.opendaylight.openflowplugin</groupId>
+                <artifactId>openflowplugin-artifacts</artifactId>
+                <version>${project.version}</version>
+                <scope>import</scope>
+                <type>pom</type>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <dependencies>
+        <!-- feature dependencies -->
+        <dependency>
+            <groupId>org.opendaylight.openflowplugin</groupId>
+            <artifactId>odl-openflowplugin-southbound</artifactId>
+            <classifier>features</classifier>
+            <type>xml</type>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.openflowplugin</groupId>
+            <artifactId>openflowjava-extension-eric</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.openflowplugin</groupId>
+            <artifactId>openflowplugin-extension-eric</artifactId>
+        </dependency>
+    </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/extension/features-extension-aggregator/odl-openflowplugin-eric-extensions/src/main/features/features.xml b/extension/features-extension-aggregator/odl-openflowplugin-eric-extensions/src/main/features/features.xml
new file mode 100644 (file)
index 0000000..0a9d63e
--- /dev/null
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<features name="openflowplugin-extension-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0">
+    <feature name="odl-openflowplugin-eric-extensions" version="${project.version}">
+    </feature>
+</features>
\ No newline at end of file
index ec82360a3f936ee41159e54f31733a1636db0a1a..90573428aa9b08d9c6b0518c050639e5a3299c40 100644 (file)
@@ -50,4 +50,4 @@
         </dependency>
     </dependencies>
 
-</project>
+</project>
\ No newline at end of file
index 59ce4da1e37ff6b878d93ac83669c27b47b8cbac..dfbc30433fb91b4c8b42abba622d4104b76638f3 100644 (file)
@@ -17,6 +17,7 @@
         <module>features-openflowplugin-extension</module>
         <module>odl-openflowplugin-nxm-extensions</module>
         <module>odl-openflowplugin-onf-extensions</module>
+        <module>odl-openflowplugin-eric-extensions</module>
     </modules>
 
 </project>
diff --git a/extension/openflowjava-extension-eric/pom.xml b/extension/openflowjava-extension-eric/pom.xml
new file mode 100644 (file)
index 0000000..20a00bd
--- /dev/null
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.opendaylight.openflowplugin</groupId>
+        <artifactId>openflowplugin-extension-parent</artifactId>
+        <version>0.9.0-SNAPSHOT</version>
+        <relativePath>../</relativePath>
+    </parent>
+    <artifactId>openflowjava-extension-eric</artifactId>
+    <packaging>bundle</packaging>
+
+    <build>
+    <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+            </plugin>
+    </plugins>
+    </build>
+
+     <dependencies>
+        <dependency>
+            <groupId>${project.groupId}.openflowjava</groupId>
+            <artifactId>openflow-protocol-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}.openflowjava</groupId>
+            <artifactId>openflow-protocol-spi</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}.openflowjava</groupId>
+            <artifactId>openflowjava-util</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>openflowjava-extension-nicira-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.netty</groupId>
+            <artifactId>netty-buffer</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+     </dependencies>
+</project>
\ No newline at end of file
diff --git a/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/EricExtensionCodecRegistratorImpl.java b/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/EricExtensionCodecRegistratorImpl.java
new file mode 100644 (file)
index 0000000..ef21514
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2019 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.eric;
+
+import java.util.List;
+import org.opendaylight.openflowjava.eric.api.EricExtensionCodecRegistrator;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterDeserializerKey;
+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.spi.connection.SwitchConnectionProvider;
+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;
+
+/**
+ * Implementation of EricExtensionCodecRegistrator.
+ */
+public class EricExtensionCodecRegistratorImpl implements EricExtensionCodecRegistrator {
+
+    private final List<SwitchConnectionProvider> providers;
+
+    public EricExtensionCodecRegistratorImpl(List<SwitchConnectionProvider> providers) {
+        this.providers = providers;
+    }
+
+    private void unregisterDeserializer(ExperimenterDeserializerKey key) {
+        for (SwitchConnectionProvider provider : providers) {
+            provider.unregisterDeserializer(key);
+        }
+    }
+
+    private void unregisterSerializer(ExperimenterSerializerKey key) {
+        for (SwitchConnectionProvider provider : providers) {
+            provider.unregisterSerializer(key);
+        }
+    }
+
+    @Override
+    public void registerMatchEntryDeserializer(MatchEntryDeserializerKey key, OFDeserializer<MatchEntry> deserializer) {
+        for (SwitchConnectionProvider provider : providers) {
+            provider.registerMatchEntryDeserializer(key, deserializer);
+        }
+    }
+
+    @Override
+    public void unregisterMatchEntryDeserializer(MatchEntryDeserializerKey key) {
+        unregisterDeserializer(key);
+    }
+
+    @Override
+    public void registerMatchEntrySerializer(MatchEntrySerializerKey<? extends OxmClassBase, ? extends MatchField> key,
+            OFSerializer<MatchEntry> serializer) {
+        for (SwitchConnectionProvider provider : providers) {
+            provider.registerMatchEntrySerializer(key, serializer);
+        }
+    }
+
+    @Override
+    public void unregisterMatchEntrySerializer(
+            MatchEntrySerializerKey<? extends OxmClassBase, ? extends MatchField> key) {
+        unregisterSerializer(key);
+    }
+
+    @Override
+    public void close() {
+        // TODO Auto-generated method stub
+    }
+
+}
diff --git a/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/EricExtensionsRegistrator.java b/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/EricExtensionsRegistrator.java
new file mode 100644 (file)
index 0000000..db017c9
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2019 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.eric;
+
+import com.google.common.base.Preconditions;
+import org.opendaylight.openflowjava.eric.api.EricExtensionCodecRegistrator;
+import org.opendaylight.openflowjava.eric.codec.match.EricMatchCodecs;
+import org.opendaylight.openflowjava.eric.codec.match.Icmpv6NDOptionsTypeCodec;
+import org.opendaylight.openflowjava.eric.codec.match.Icmpv6NDReservedCodec;
+
+public class EricExtensionsRegistrator implements AutoCloseable {
+    private final EricExtensionCodecRegistrator registrator;
+
+    public EricExtensionsRegistrator(EricExtensionCodecRegistrator registrator) {
+        this.registrator = Preconditions.checkNotNull(registrator);
+        registrator.registerMatchEntrySerializer(Icmpv6NDReservedCodec.SERIALIZER_KEY,
+                EricMatchCodecs.ICMPV_6_ND_RESERVED_CODEC);
+        registrator.registerMatchEntrySerializer(Icmpv6NDOptionsTypeCodec.SERIALIZER_KEY,
+                EricMatchCodecs.ICMPV_6_ND_OPTIONS_TYPE_CODEC);
+        registrator.registerMatchEntryDeserializer(Icmpv6NDReservedCodec.DESERIALIZER_KEY,
+                EricMatchCodecs.ICMPV_6_ND_RESERVED_CODEC);
+        registrator.registerMatchEntryDeserializer(Icmpv6NDOptionsTypeCodec.DESERIALIZER_KEY,
+                EricMatchCodecs.ICMPV_6_ND_OPTIONS_TYPE_CODEC);
+    }
+
+    @Override
+    public void close()  {
+        registrator.unregisterMatchEntrySerializer(Icmpv6NDReservedCodec.SERIALIZER_KEY);
+        registrator.unregisterMatchEntrySerializer(Icmpv6NDOptionsTypeCodec.SERIALIZER_KEY);
+        registrator.unregisterMatchEntryDeserializer(Icmpv6NDReservedCodec.DESERIALIZER_KEY);
+        registrator.unregisterMatchEntryDeserializer(Icmpv6NDOptionsTypeCodec.DESERIALIZER_KEY);
+    }
+
+}
\ No newline at end of file
diff --git a/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/api/EricConstants.java b/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/api/EricConstants.java
new file mode 100644 (file)
index 0000000..9d85bfe
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2019 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.eric.api;
+
+public final class EricConstants {
+
+    private EricConstants() {}
+
+    /** Experimenter ID of ONF approved extensions. */
+    public static final int ERICOXM_OF_EXPERIMENTER_ID = 0x1000;
+
+    /** ERICOXM_OF_ICMPV6_ND_RESERVED message type. */
+    public static final int ERICOXM_OF_ICMPV6_ND_RESERVED = 1;
+
+    /** ERICOXM_OF_ICMPV6_ND_OPTION_TYPE message type. */
+    public static final int ERICOXM_OF_ICMPV6_ND_OPTIONS_TYPE = 2;
+
+}
\ No newline at end of file
diff --git a/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/api/EricExtensionCodecRegistrator.java b/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/api/EricExtensionCodecRegistrator.java
new file mode 100644 (file)
index 0000000..a0c6644
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2019 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.eric.api;
+
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+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.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;
+
+/**
+ * Registry for Ericsson extension codecs.
+ */
+public interface EricExtensionCodecRegistrator extends AutoCloseable {
+
+    void registerMatchEntryDeserializer(MatchEntryDeserializerKey key, OFDeserializer<MatchEntry> deserializer);
+
+    void unregisterMatchEntryDeserializer(MatchEntryDeserializerKey key);
+
+    void registerMatchEntrySerializer(MatchEntrySerializerKey<? extends OxmClassBase, ? extends MatchField> key,
+            OFSerializer<MatchEntry> serializer);
+
+    void unregisterMatchEntrySerializer(MatchEntrySerializerKey<? extends OxmClassBase, ? extends MatchField> key);
+
+}
\ No newline at end of file
diff --git a/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/codec/match/AbstractMatchCodec.java b/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/codec/match/AbstractMatchCodec.java
new file mode 100644 (file)
index 0000000..0afd30a
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2019 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.eric.codec.match;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer;
+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.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;
+
+public abstract class AbstractMatchCodec implements
+        OFSerializer<MatchEntry>,
+        OFDeserializer<MatchEntry>,
+        HeaderSerializer<MatchEntry>,
+        HeaderDeserializer<MatchEntry> {
+
+    protected EricHeader headerWithMask;
+    protected EricHeader headerWithoutMask;
+
+    protected MatchEntryBuilder deserializeHeaderToBuilder(ByteBuf message) {
+        MatchEntryBuilder builder = new MatchEntryBuilder();
+        builder.setOxmClass(getOxmClass());
+        // skip oxm_class - provided
+        message.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+        builder.setOxmMatchField(getEricField());
+        boolean hasMask = (message.readUnsignedByte() & 1) != 0;
+        builder.setHasMask(hasMask);
+        // skip experimenter class, match length and experimenter id - not needed
+        message.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
+        return builder;
+    }
+
+    @Override
+    public MatchEntry deserializeHeader(ByteBuf message) {
+        return deserializeHeaderToBuilder(message).build();
+    }
+
+    @Override
+    public void serializeHeader(MatchEntry input, ByteBuf outBuffer) {
+        serializeHeader(getHeader(input.isHasMask()), outBuffer);
+    }
+
+    public void serializeHeader(EricHeader input, ByteBuf outBuffer) {
+        outBuffer.writeInt((int) input.toLong());
+    }
+
+    protected EricHeader getHeader(boolean hasMask) {
+        if (hasMask) {
+            if (headerWithMask == null) {
+                headerWithMask = buildHeader(hasMask);
+            }
+            return headerWithMask;
+        } else {
+            if (headerWithoutMask == null) {
+                headerWithoutMask = buildHeader(hasMask);
+            }
+            return headerWithoutMask;
+        }
+    }
+
+    protected EricHeader buildHeader(boolean hasMask) {
+        return new EricHeader(
+                getOxmClassCode(),
+                getEricFieldCode(),
+                hasMask,
+                hasMask ? getValueLength() * 2 : getValueLength()
+        );
+    }
+
+    public EricHeader getHeaderWithoutHasMask() {
+        return getHeader(false);
+    }
+
+    public EricHeader getHeaderWithHasMask() {
+        return getHeader(true);
+    }
+
+    /**
+     * Returns the numeric representation of eric_field.
+     */
+    public abstract int getEricFieldCode();
+
+    /**
+     * Returns the numeric representation of oxm_class.
+     */
+    public abstract int getOxmClassCode();
+
+    /**
+     * Returns the match entry value length.
+     */
+    public abstract int getValueLength();
+
+    /**
+     * Returns the eric_field class.
+     */
+    public abstract Class<? extends MatchField> getEricField();
+
+    /**
+     * Returns the oxm_class class.
+     */
+    public abstract Class<? extends OxmClassBase> getOxmClass();
+}
\ No newline at end of file
diff --git a/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/codec/match/EricHeader.java b/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/codec/match/EricHeader.java
new file mode 100644 (file)
index 0000000..bde655e
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2018 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.eric.codec.match;
+
+import com.google.common.primitives.Ints;
+
+/**
+ * Eric header.
+ */
+public class EricHeader {
+
+    private final long headerAsLong;
+    private final int oxmClass;
+    private final int ericField;
+    private final boolean hasMask;
+    private final int length;
+
+    public EricHeader(long header) {
+        this.headerAsLong = header;
+        this.oxmClass = Ints.checkedCast(extractSub(header, 16, 16));
+        this.ericField = Ints.checkedCast(extractSub(header, 7, 9));
+        this.hasMask = extractSub(header, 1, 8) == 1 ? true : false;
+        this.length = Ints.checkedCast(extractSub(header, 8, 0));
+    }
+
+    public EricHeader(int oxmClass, int ericField, boolean hasMask, int length) {
+        this.oxmClass = oxmClass;
+        this.ericField = ericField;
+        this.hasMask = hasMask;
+        this.length = length;
+        this.headerAsLong = (long) oxmClass << 16 | ericField << 9 | (hasMask ? 1 : 0) << 8 | length;
+    }
+
+    private static long extractSub(final long value, final int nrBits, final int offset) {
+        final long rightShifted = value >>> offset;
+        final long mask = (1L << nrBits) - 1L;
+        return rightShifted & mask;
+    }
+
+    public long toLong() {
+        return headerAsLong;
+    }
+
+    public int getOxmClass() {
+        return oxmClass;
+    }
+
+    public int getEricField() {
+        return ericField;
+    }
+
+    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;
+        }
+        EricHeader other = (EricHeader) obj;
+        if (headerAsLong != other.headerAsLong) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        return "EricHeader [headerAsLong=" + headerAsLong + ", oxmClass=" + oxmClass + ", ericField=" + ericField
+                 + ", hasMask=" + hasMask + ", length=" + length + "]";
+    }
+
+}
\ No newline at end of file
diff --git a/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/codec/match/EricMatchCodecs.java b/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/codec/match/EricMatchCodecs.java
new file mode 100644 (file)
index 0000000..4e24d04
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2019 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.eric.codec.match;
+
+/**
+ * Defines Eric match codecs.
+ */
+public interface EricMatchCodecs {
+
+    Icmpv6NDReservedCodec ICMPV_6_ND_RESERVED_CODEC = new Icmpv6NDReservedCodec();
+    Icmpv6NDOptionsTypeCodec ICMPV_6_ND_OPTIONS_TYPE_CODEC = new Icmpv6NDOptionsTypeCodec();
+
+}
\ No newline at end of file
diff --git a/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/codec/match/Icmpv6NDOptionsTypeCodec.java b/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/codec/match/Icmpv6NDOptionsTypeCodec.java
new file mode 100644 (file)
index 0000000..0490ea0
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2019 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.eric.codec.match;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.eric.api.EricConstants;
+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.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EricExpClass;
+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;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.Icmpv6NdOptionsType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.icmpv6.nd.options.type.grouping.Icmpv6NdOptionsTypeValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.oxm.container.match.entry.value.Icmpv6NdOptionsTypeCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.oxm.container.match.entry.value.Icmpv6NdOptionsTypeCaseValueBuilder;
+
+public class Icmpv6NDOptionsTypeCodec extends AbstractMatchCodec {
+
+    private static final int VALUE_LENGTH = 1;
+    public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey(
+            EncodeConstants.OF13_VERSION_ID, EricExpClass.class, Icmpv6NdOptionsType.class);
+    public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
+            EncodeConstants.OF13_VERSION_ID, EricConstants.ERICOXM_OF_EXPERIMENTER_ID,
+            EricConstants.ERICOXM_OF_ICMPV6_ND_OPTIONS_TYPE);
+
+    @Override
+    public void serialize(MatchEntry input, ByteBuf outBuffer) {
+        serializeHeader(input, outBuffer);
+        Icmpv6NdOptionsTypeCaseValue caseValue = ((Icmpv6NdOptionsTypeCaseValue) input.getMatchEntryValue());
+        outBuffer.writeByte(caseValue.getIcmpv6NdOptionsTypeValues().getIcmpv6NdOptionsType());
+    }
+
+    @Override
+    public MatchEntry deserialize(ByteBuf message) {
+        MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message);
+        Icmpv6NdOptionsTypeCaseValueBuilder caseBuilder = new Icmpv6NdOptionsTypeCaseValueBuilder();
+        caseBuilder.setIcmpv6NdOptionsTypeValues(new Icmpv6NdOptionsTypeValuesBuilder()
+                .setIcmpv6NdOptionsType(message.readUnsignedByte()).build());
+        matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
+        return matchEntryBuilder.build();
+    }
+
+    @Override
+    public int getEricFieldCode() {
+        return EricConstants.ERICOXM_OF_ICMPV6_ND_OPTIONS_TYPE;
+    }
+
+    @Override
+    public int getOxmClassCode() {
+        return EricConstants.ERICOXM_OF_EXPERIMENTER_ID;
+    }
+
+    @Override
+    public int getValueLength() {
+        return VALUE_LENGTH;
+    }
+
+    @Override
+    public Class<? extends MatchField> getEricField() {
+        return Icmpv6NdOptionsType.class;
+    }
+
+    @Override
+    public Class<? extends OxmClassBase> getOxmClass() {
+        return EricExpClass.class;
+    }
+
+}
\ No newline at end of file
diff --git a/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/codec/match/Icmpv6NDReservedCodec.java b/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/codec/match/Icmpv6NDReservedCodec.java
new file mode 100644 (file)
index 0000000..722a246
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2019 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.eric.codec.match;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.eric.api.EricConstants;
+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.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EricExpClass;
+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;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.Icmpv6NdReserved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.icmpv6.nd.reserved.grouping.Icmpv6NdReservedValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.oxm.container.match.entry.value.Icmpv6NdReservedCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.oxm.container.match.entry.value.Icmpv6NdReservedCaseValueBuilder;
+
+public class Icmpv6NDReservedCodec extends AbstractMatchCodec {
+
+    private static final int VALUE_LENGTH = 4;
+    public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey(
+             EncodeConstants.OF13_VERSION_ID, EricExpClass.class, Icmpv6NdReserved.class);
+    public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
+            EncodeConstants.OF13_VERSION_ID, EricConstants.ERICOXM_OF_EXPERIMENTER_ID,
+            EricConstants.ERICOXM_OF_ICMPV6_ND_RESERVED);
+
+    @Override
+    public void serialize(MatchEntry input, ByteBuf outBuffer) {
+        serializeHeader(input, outBuffer);
+        Icmpv6NdReservedCaseValue caseValue = ((Icmpv6NdReservedCaseValue) input.getMatchEntryValue());
+        outBuffer.writeInt(caseValue.getIcmpv6NdReservedValues().getIcmpv6NdReserved().intValue());
+    }
+
+    @Override
+    public MatchEntry deserialize(ByteBuf message) {
+        MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message);
+        Icmpv6NdReservedCaseValueBuilder caseBuilder = new Icmpv6NdReservedCaseValueBuilder();
+        caseBuilder.setIcmpv6NdReservedValues(new Icmpv6NdReservedValuesBuilder()
+                .setIcmpv6NdReserved(message.readUnsignedInt()).build());
+        matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
+        return matchEntryBuilder.build();
+    }
+
+    @Override
+    public int getEricFieldCode() {
+        return EricConstants.ERICOXM_OF_ICMPV6_ND_RESERVED;
+    }
+
+    @Override
+    public int getOxmClassCode() {
+        return EricConstants.ERICOXM_OF_EXPERIMENTER_ID;
+    }
+
+    @Override
+    public int getValueLength() {
+        return VALUE_LENGTH;
+    }
+
+    @Override
+    public Class<? extends MatchField> getEricField() {
+        return Icmpv6NdReserved.class;
+    }
+
+    @Override
+    public Class<? extends OxmClassBase> getOxmClass() {
+        return EricExpClass.class;
+    }
+
+}
\ No newline at end of file
diff --git a/extension/openflowjava-extension-eric/src/main/resources/org/opendaylight/blueprint/openflowjava-extension-eric.xml b/extension/openflowjava-extension-eric/src/main/resources/org/opendaylight/blueprint/openflowjava-extension-eric.xml
new file mode 100644 (file)
index 0000000..5488873
--- /dev/null
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+           xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
+           odl:use-default-for-reference-types="true">
+
+    <reference id="defaultSwitchConnProvider"
+               interface="org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider"
+               odl:type="openflow-switch-connection-provider-default-impl"/>
+
+    <reference id="legacySwitchConnProvider"
+               interface="org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider"
+               odl:type="openflow-switch-connection-provider-legacy-impl"/>
+
+    <bean id="ericExtensionCodecRegistrator"
+          class="org.opendaylight.openflowjava.eric.EricExtensionCodecRegistratorImpl"
+          destroy-method="close">
+         <argument>
+            <list>
+                <ref component-id="defaultSwitchConnProvider"/>
+                <ref component-id="legacySwitchConnProvider"/>
+            </list>
+        </argument>
+    </bean>
+
+    <bean id="ericExtensionsRegistrator"
+          class="org.opendaylight.openflowjava.eric.EricExtensionsRegistrator"
+          destroy-method="close">
+        <argument ref="ericExtensionCodecRegistrator"/>
+    </bean>
+
+    <service ref="ericExtensionCodecRegistrator"
+             interface="org.opendaylight.openflowjava.eric.api.EricExtensionCodecRegistrator"/>
+
+</blueprint>
\ No newline at end of file
diff --git a/extension/openflowjava-extension-eric/src/main/yang/eric-match.yang b/extension/openflowjava-extension-eric/src/main/yang/eric-match.yang
new file mode 100644 (file)
index 0000000..1efaa2a
--- /dev/null
@@ -0,0 +1,55 @@
+module eric-match {
+    yang-version 1;
+
+    namespace "urn:opendaylight:openflowjava:eric:match";
+    prefix "eric-match";
+
+    import openflow-extensible-match {prefix ofoxm;}
+    import yang-ext {prefix ext; revision-date "2013-07-09";}
+
+    description
+        "Eric openflow extensions of match.";
+
+    revision "2018-07-30" {
+        description "Initial revision";
+    }
+
+    identity icmpv6-nd-reserved {
+        base ofoxm:match-field;
+    }
+
+    identity icmpv6-nd-options-type {
+        base ofoxm:match-field;
+    }
+
+    grouping icmpv6-nd-reserved-grouping {
+        container icmpv6-nd-reserved-values {
+             leaf icmpv6-nd-reserved {
+                 type uint32;
+             }
+        }
+    }
+
+    grouping icmpv6-nd-options-type-grouping {
+        container icmpv6-nd-options-type-values {
+             leaf icmpv6-nd-options-type {
+                 type uint8;
+             }
+        }
+    }
+
+    augment "/ofoxm:oxm-container/ofoxm:match-entry-value" {
+        ext:augment-identifier "ofj-aug-eric-match";
+        case icmpv6-nd-reserved-case-value {
+            uses icmpv6-nd-reserved-grouping;
+        }
+    }
+
+    augment "/ofoxm:oxm-container/ofoxm:match-entry-value" {
+        ext:augment-identifier "ofj-aug-eric-match";
+        case icmpv6-nd-options-type-case-value {
+            uses icmpv6-nd-options-type-grouping;
+        }
+    }
+
+}
\ No newline at end of file
diff --git a/extension/openflowjava-extension-eric/src/test/java/org/opendaylight/openflowjava/eric/EricExtensionCodecRegistratorImplTest.java b/extension/openflowjava-extension-eric/src/test/java/org/opendaylight/openflowjava/eric/EricExtensionCodecRegistratorImplTest.java
new file mode 100644 (file)
index 0000000..73b39df
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2019 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.eric;
+
+import java.util.LinkedList;
+import java.util.List;
+import org.junit.Before;
+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.extensibility.OFDeserializer;
+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.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EricExpClass;
+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;
+
+@RunWith(MockitoJUnitRunner.class)
+public class EricExtensionCodecRegistratorImplTest {
+
+    public static final short VERSION = 4;
+    public static final byte VERSION1 = EncodeConstants.OF10_VERSION_ID;
+    public static final byte VERSION2 = EncodeConstants.OF13_VERSION_ID;
+
+    private EricExtensionCodecRegistratorImpl ericExtensionCodecRegistrator;
+    private List<SwitchConnectionProvider> providers = new LinkedList<>();
+    private MatchEntrySerializerKey matchSerializerKey;
+    private MatchEntryDeserializerKey matchDeserializerKey;
+
+    @Mock
+    OFSerializer<MatchEntry> matchSerializer;
+    @Mock
+    OFDeserializer<MatchEntry> matchDeserializer;
+    @Mock
+    SwitchConnectionProvider provider;
+
+    @Before
+    public void setUp() {
+        providers.add(provider);
+        matchSerializerKey = new MatchEntrySerializerKey(VERSION, EricExpClass.class, MatchField.class);
+        //OxmClass 1, OxmField 2
+        matchDeserializerKey = new MatchEntryDeserializerKey(VERSION, 1, 2);
+
+        ericExtensionCodecRegistrator = new EricExtensionCodecRegistratorImpl(providers);
+    }
+
+    @Test
+    public void registerMatchEntrySerializerTest() {
+        ericExtensionCodecRegistrator.registerMatchEntrySerializer(matchSerializerKey, matchSerializer);
+        Mockito.verify(provider).registerMatchEntrySerializer(matchSerializerKey, matchSerializer);
+    }
+
+    @Test
+    public void unregisterMatchEntrySerializerTest() {
+        ericExtensionCodecRegistrator.unregisterMatchEntrySerializer(matchSerializerKey);
+        Mockito.verify(provider).unregisterSerializer(matchSerializerKey);
+    }
+
+    @Test
+    public void registerMatchEntryDeserializerTest() {
+        ericExtensionCodecRegistrator.registerMatchEntryDeserializer(matchDeserializerKey, matchDeserializer);
+        Mockito.verify(provider).registerMatchEntryDeserializer(matchDeserializerKey, matchDeserializer);
+    }
+
+    @Test
+    public void unregisterMatchEntryDeserializerTest() {
+        ericExtensionCodecRegistrator.unregisterMatchEntryDeserializer(matchDeserializerKey);
+        Mockito.verify(provider).unregisterDeserializer(matchDeserializerKey);
+    }
+
+}
\ No newline at end of file
diff --git a/extension/openflowjava-extension-eric/src/test/java/org/opendaylight/openflowjava/eric/EricExtensionsRegistratorTest.java b/extension/openflowjava-extension-eric/src/test/java/org/opendaylight/openflowjava/eric/EricExtensionsRegistratorTest.java
new file mode 100644 (file)
index 0000000..16611c7
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2019 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.eric;
+
+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.eric.api.EricConstants;
+import org.opendaylight.openflowjava.eric.api.EricExtensionCodecRegistrator;
+import org.opendaylight.openflowjava.eric.codec.match.Icmpv6NDOptionsTypeCodec;
+import org.opendaylight.openflowjava.eric.codec.match.Icmpv6NDReservedCodec;
+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.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EricExpClass;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.Icmpv6NdOptionsType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.Icmpv6NdReserved;
+
+@RunWith(MockitoJUnitRunner.class)
+public class EricExtensionsRegistratorTest {
+
+    private EricExtensionsRegistrator ericExtensionsRegistrator;
+
+    @Mock
+    EricExtensionCodecRegistrator registrator;
+
+    @Before
+    public void setUp() {
+        ericExtensionsRegistrator = new EricExtensionsRegistrator(registrator);
+    }
+
+    @Test
+    public void registerEricExtensionsTest() {
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers
+                .eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, EricExpClass.class,
+                        Icmpv6NdReserved.class)), Matchers.any(Icmpv6NDReservedCodec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers
+                .eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID,
+                        EricConstants.ERICOXM_OF_EXPERIMENTER_ID, EricConstants.ERICOXM_OF_ICMPV6_ND_RESERVED)),
+                Matchers.any(Icmpv6NDReservedCodec.class));
+
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers
+                        .eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, EricExpClass.class,
+                                Icmpv6NdOptionsType.class)), Matchers.any(Icmpv6NDOptionsTypeCodec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers
+                        .eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID,
+                                EricConstants.ERICOXM_OF_EXPERIMENTER_ID,
+                                EricConstants.ERICOXM_OF_ICMPV6_ND_OPTIONS_TYPE)),
+                Matchers.any(Icmpv6NDOptionsTypeCodec.class));
+    }
+
+    @Test
+    public void unregisterExtensionsTest() {
+        ericExtensionsRegistrator.close();
+
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(
+                new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, EricExpClass.class,
+                        Icmpv6NdReserved.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(
+                new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, EricConstants.ERICOXM_OF_EXPERIMENTER_ID,
+                        EricConstants.ERICOXM_OF_ICMPV6_ND_RESERVED));
+
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(
+                new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, EricExpClass.class,
+                        Icmpv6NdOptionsType.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(
+                new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, EricConstants.ERICOXM_OF_EXPERIMENTER_ID,
+                         EricConstants.ERICOXM_OF_ICMPV6_ND_OPTIONS_TYPE));
+    }
+
+}
\ No newline at end of file
diff --git a/extension/openflowjava-extension-eric/src/test/java/org/opendaylight/openflowjava/eric/codec/match/EricHeaderTest.java b/extension/openflowjava-extension-eric/src/test/java/org/opendaylight/openflowjava/eric/codec/match/EricHeaderTest.java
new file mode 100644 (file)
index 0000000..239881b
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2019 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.eric.codec.match;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.eric.api.EricConstants;
+
+public class EricHeaderTest {
+
+    private static final int ERIC_FIELD_CODE = 4;
+    private static final int VALUE_LENGTH = 14;
+    private static long header;
+
+    private EricHeader ericHeader;
+
+    @Test
+    public void ericHeaderTest() {
+        header = createHeader();
+        ericHeader = new EricHeader(header);
+        assertEquals(EricConstants.ERICOXM_OF_EXPERIMENTER_ID, ericHeader.getOxmClass());
+        assertEquals(ERIC_FIELD_CODE, ericHeader.getEricField());
+        assertEquals(false, ericHeader.isHasMask());
+        assertEquals(VALUE_LENGTH, ericHeader.getLength());
+    }
+
+    @Test
+    public void equalsTest() {
+        Object notHeader = new Object();
+        header = createHeader();
+        ericHeader = new EricHeader(header);
+        assertFalse(ericHeader.equals(notHeader));
+    }
+
+    @Test
+    public void equalsTest1() {
+        header = createHeader();
+        ericHeader = new EricHeader(header);
+
+        assertTrue(ericHeader.equals(ericHeader));
+    }
+
+    @Test
+    public void toStringTest() {
+        header = createHeader();
+        ericHeader = new EricHeader(header);
+
+        String shouldBe = new String("EricHeader " + "[headerAsLong=" + header + ", " + "oxmClass="
+               + EricConstants.ERICOXM_OF_EXPERIMENTER_ID + "," + " ericField=" + ERIC_FIELD_CODE + "," + " hasMask="
+                + false + "," + " length=" + VALUE_LENGTH + "]");
+        assertEquals(shouldBe, ericHeader.toString());
+    }
+
+    private long createHeader() {
+        long result = 0;
+        int oxmClass = 4096 << 16;
+        result = result | oxmClass;
+        int oxmField = ERIC_FIELD_CODE << 9;
+        result = result | oxmField;
+        int mask = 0 << 8;
+        result = result | mask;
+        int length = VALUE_LENGTH;
+        result = result | length;
+        return result;
+    }
+
+}
\ No newline at end of file
diff --git a/extension/openflowjava-extension-eric/src/test/java/org/opendaylight/openflowjava/eric/codec/match/Icmpv6NDOptionsTypeCodecTest.java b/extension/openflowjava-extension-eric/src/test/java/org/opendaylight/openflowjava/eric/codec/match/Icmpv6NDOptionsTypeCodecTest.java
new file mode 100644 (file)
index 0000000..78c1d28
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2019 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.eric.codec.match;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufAllocator;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.eric.api.EricConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EricExpClass;
+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.openflowjava.eric.match.rev180730.Icmpv6NdOptionsType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.icmpv6.nd.options.type.grouping.Icmpv6NdOptionsTypeValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.oxm.container.match.entry.value.Icmpv6NdOptionsTypeCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.oxm.container.match.entry.value.Icmpv6NdOptionsTypeCaseValueBuilder;
+
+
+public class Icmpv6NDOptionsTypeCodecTest {
+
+    private static final int ERIC_FIELD_CODE = 2;
+    private static final int VALUE_LENGTH = 1;
+
+    private Icmpv6NDOptionsTypeCodec icmpv6NDOptionsTypeCodec;
+    private ByteBuf buffer;
+    private MatchEntry input;
+
+    @Before
+    public void setUp() {
+        icmpv6NDOptionsTypeCodec = new Icmpv6NDOptionsTypeCodec();
+        buffer = ByteBufAllocator.DEFAULT.buffer();
+    }
+
+    @Test
+    public void serializeTest() {
+        input = createMatchEntry();
+        icmpv6NDOptionsTypeCodec.serialize(input, buffer);
+
+        assertEquals(EricConstants.ERICOXM_OF_EXPERIMENTER_ID,
+                buffer.readUnsignedShort());
+        short fieldMask = buffer.readUnsignedByte();
+        assertEquals(ERIC_FIELD_CODE, fieldMask >> 1);
+        assertEquals(0, fieldMask & 1);
+        assertEquals(VALUE_LENGTH, buffer.readUnsignedByte());
+        assertEquals(1, buffer.readUnsignedByte());
+    }
+
+    @Test
+    public void deserializeTest() {
+        createBuffer(buffer);
+
+        input = icmpv6NDOptionsTypeCodec.deserialize(buffer);
+
+        final Icmpv6NdOptionsTypeCaseValue result = (Icmpv6NdOptionsTypeCaseValue) input.getMatchEntryValue();
+        assertEquals(EricExpClass.class, input.getOxmClass());
+        assertEquals(Icmpv6NdOptionsType.class, input.getOxmMatchField());
+        assertEquals(false, input.isHasMask());
+        assertEquals(2, result.getIcmpv6NdOptionsTypeValues().getIcmpv6NdOptionsType().shortValue());
+    }
+
+    private MatchEntry createMatchEntry() {
+        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+        final Icmpv6NdOptionsTypeCaseValueBuilder caseBuilder = new Icmpv6NdOptionsTypeCaseValueBuilder();
+        final Icmpv6NdOptionsTypeValuesBuilder valuesBuilder = new Icmpv6NdOptionsTypeValuesBuilder();
+
+        matchEntryBuilder.setOxmClass(EricExpClass.class);
+        matchEntryBuilder.setOxmMatchField(Icmpv6NdOptionsType.class);
+        matchEntryBuilder.setHasMask(false);
+
+        valuesBuilder.setIcmpv6NdOptionsType((short)1);
+
+        caseBuilder.setIcmpv6NdOptionsTypeValues(valuesBuilder.build());
+        matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
+        return matchEntryBuilder.build();
+    }
+
+    private void createBuffer(ByteBuf message) {
+        message.writeShort(EricConstants.ERICOXM_OF_EXPERIMENTER_ID);
+
+        int fieldMask = ERIC_FIELD_CODE << 1;
+        message.writeByte(fieldMask);
+        message.writeByte(VALUE_LENGTH);
+        message.writeByte(2);
+    }
+
+}
\ No newline at end of file
diff --git a/extension/openflowjava-extension-eric/src/test/java/org/opendaylight/openflowjava/eric/codec/match/Icmpv6NDReservedCodecTest.java b/extension/openflowjava-extension-eric/src/test/java/org/opendaylight/openflowjava/eric/codec/match/Icmpv6NDReservedCodecTest.java
new file mode 100644 (file)
index 0000000..fd66b61
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2019 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.eric.codec.match;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufAllocator;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.eric.api.EricConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EricExpClass;
+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.openflowjava.eric.match.rev180730.Icmpv6NdReserved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.icmpv6.nd.reserved.grouping.Icmpv6NdReservedValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.oxm.container.match.entry.value.Icmpv6NdReservedCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.oxm.container.match.entry.value.Icmpv6NdReservedCaseValueBuilder;
+
+public class Icmpv6NDReservedCodecTest {
+
+    private static final int ERIC_FIELD_CODE = 1;
+    private static final int VALUE_LENGTH = 4;
+
+    private Icmpv6NDReservedCodec icmpv6NDReservedCodec;
+    private ByteBuf buffer;
+    private MatchEntry input;
+
+    @Before
+    public void setUp() {
+        icmpv6NDReservedCodec = new Icmpv6NDReservedCodec();
+        buffer = ByteBufAllocator.DEFAULT.buffer();
+    }
+
+    @Test
+    public void serializeTest() {
+        input = createMatchEntry();
+        icmpv6NDReservedCodec.serialize(input, buffer);
+
+        assertEquals(EricConstants.ERICOXM_OF_EXPERIMENTER_ID,
+                buffer.readUnsignedShort());
+        short fieldMask = buffer.readUnsignedByte();
+        assertEquals(ERIC_FIELD_CODE, fieldMask >> 1);
+        assertEquals(0, fieldMask & 1);
+        assertEquals(VALUE_LENGTH, buffer.readUnsignedByte());
+        assertEquals(1, buffer.readUnsignedInt());
+    }
+
+    @Test
+    public void deserializeTest() {
+        createBuffer(buffer);
+        input = icmpv6NDReservedCodec.deserialize(buffer);
+        final Icmpv6NdReservedCaseValue result = (Icmpv6NdReservedCaseValue) input.getMatchEntryValue();
+
+        assertEquals(EricExpClass.class, input.getOxmClass());
+        assertEquals(Icmpv6NdReserved.class, input.getOxmMatchField());
+        assertEquals(false, input.isHasMask());
+        assertEquals(2, result.getIcmpv6NdReservedValues().getIcmpv6NdReserved().intValue());
+    }
+
+    private MatchEntry createMatchEntry() {
+        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+        final Icmpv6NdReservedCaseValueBuilder caseBuilder = new Icmpv6NdReservedCaseValueBuilder();
+        final Icmpv6NdReservedValuesBuilder valuesBuilder = new Icmpv6NdReservedValuesBuilder();
+
+        matchEntryBuilder.setOxmClass(EricExpClass.class);
+        matchEntryBuilder.setOxmMatchField(Icmpv6NdReserved.class);
+        matchEntryBuilder.setHasMask(false);
+
+        valuesBuilder.setIcmpv6NdReserved(1L);
+        caseBuilder.setIcmpv6NdReservedValues(valuesBuilder.build());
+        matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
+        return matchEntryBuilder.build();
+    }
+
+    private void createBuffer(ByteBuf message) {
+        message.writeShort(EricConstants.ERICOXM_OF_EXPERIMENTER_ID);
+        int fieldMask = ERIC_FIELD_CODE << 1;
+        message.writeByte(fieldMask);
+        message.writeByte(VALUE_LENGTH);
+        message.writeInt(2);
+    }
+}
\ No newline at end of file
diff --git a/extension/openflowplugin-extension-eric/pom.xml b/extension/openflowplugin-extension-eric/pom.xml
new file mode 100644 (file)
index 0000000..4eee444
--- /dev/null
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+    <groupId>org.opendaylight.openflowplugin</groupId>
+        <artifactId>openflowplugin-extension-parent</artifactId>
+        <version>0.9.0-SNAPSHOT</version>
+       <relativePath>../</relativePath>
+    </parent>
+
+    <artifactId>openflowplugin-extension-eric</artifactId>
+    <packaging>bundle</packaging>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+    <dependency>
+          <groupId>${project.groupId}</groupId>
+            <artifactId>openflowplugin-extension-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>openflowjava-extension-eric</artifactId>
+        </dependency>
+        <!-- MD-SAL models -->
+        <dependency>
+            <groupId>${project.groupId}.model</groupId>
+            <artifactId>model-flow-base</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}.model</groupId>
+            <artifactId>model-flow-service</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}.model</groupId>
+            <artifactId>model-flow-statistics</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller.model</groupId>
+            <artifactId>model-inventory</artifactId>
+        </dependency>
+        <!-- OpenFlowJava-API models -->
+        <dependency>
+            <groupId>${project.groupId}.openflowjava</groupId>
+            <artifactId>openflow-protocol-api</artifactId>
+        </dependency>
+        <!-- Test dependencies -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/extension/openflowplugin-extension-eric/src/main/java/org/opendaylight/openflowplugin/extension/vendor/eric/EricExtensionProvider.java b/extension/openflowplugin-extension-eric/src/main/java/org/opendaylight/openflowplugin/extension/vendor/eric/EricExtensionProvider.java
new file mode 100644 (file)
index 0000000..dd1d80c
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2019 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.extension.vendor.eric;
+
+import com.google.common.base.Preconditions;
+import java.util.HashSet;
+import java.util.Set;
+import org.opendaylight.openflowjava.eric.codec.match.Icmpv6NDOptionsTypeCodec;
+import org.opendaylight.openflowjava.eric.codec.match.Icmpv6NDReservedCodec;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowplugin.extension.api.ConverterExtensionKey;
+import org.opendaylight.openflowplugin.extension.api.ExtensionConverterRegistrator;
+import org.opendaylight.openflowplugin.extension.api.OpenFlowPluginExtensionRegistratorProvider;
+import org.opendaylight.openflowplugin.extension.vendor.eric.convertor.match.Icmpv6NDOptionsTypeConvertor;
+import org.opendaylight.openflowplugin.extension.vendor.eric.convertor.match.Icmpv6NDReservedConvertor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.Icmpv6NdOptionsTypeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.Icmpv6NdReservedKey;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class EricExtensionProvider implements AutoCloseable {
+
+    private static final Logger LOG = LoggerFactory.getLogger(EricExtensionProvider.class);
+    private static final Icmpv6NDReservedConvertor ICMPV6_ND_RESERVED_CONVERTOR = new Icmpv6NDReservedConvertor();
+    private static final Icmpv6NDOptionsTypeConvertor ICMPV6_ND_OPTIONS_TYPE_CONVERTOR
+            = new Icmpv6NDOptionsTypeConvertor();
+
+    private final ExtensionConverterRegistrator extensionConverterRegistrator;
+    private final Set<ObjectRegistration<?>> registrations;
+
+    /**
+     * Register appropriate converters.
+     */
+    public EricExtensionProvider(final OpenFlowPluginExtensionRegistratorProvider provider) {
+        this.extensionConverterRegistrator = Preconditions.checkNotNull(provider.getExtensionConverterRegistrator());
+        registrations = new HashSet<>();
+
+        registrations.add(extensionConverterRegistrator.registerMatchConvertor(
+                new ConverterExtensionKey<>(Icmpv6NdReservedKey.class, EncodeConstants.OF13_VERSION_ID),
+                ICMPV6_ND_RESERVED_CONVERTOR));
+        registrations.add(extensionConverterRegistrator.registerMatchConvertor(Icmpv6NDReservedCodec.SERIALIZER_KEY,
+                ICMPV6_ND_RESERVED_CONVERTOR));
+
+        registrations.add(extensionConverterRegistrator.registerMatchConvertor(
+                new ConverterExtensionKey<>(Icmpv6NdOptionsTypeKey.class, EncodeConstants.OF13_VERSION_ID),
+                ICMPV6_ND_OPTIONS_TYPE_CONVERTOR));
+        registrations.add(extensionConverterRegistrator.registerMatchConvertor(Icmpv6NDOptionsTypeCodec.SERIALIZER_KEY,
+                ICMPV6_ND_OPTIONS_TYPE_CONVERTOR));
+    }
+
+    @Override
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    public void close() {
+        registrations.forEach(janitor -> {
+            try {
+                janitor.close();
+            } catch (RuntimeException e) {
+                LOG.warn("closing of extension converter failed", e);
+            }
+        });
+        registrations.clear();
+    }
+
+}
\ No newline at end of file
diff --git a/extension/openflowplugin-extension-eric/src/main/java/org/opendaylight/openflowplugin/extension/vendor/eric/convertor/CodecPreconditionException.java b/extension/openflowplugin-extension-eric/src/main/java/org/opendaylight/openflowplugin/extension/vendor/eric/convertor/CodecPreconditionException.java
new file mode 100644 (file)
index 0000000..6a95086
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2019 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.extension.vendor.eric.convertor;
+
+import org.opendaylight.openflowplugin.extension.api.path.AugmentationPath;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension;
+
+/**
+ * Codec precondition exception.
+ */
+public class CodecPreconditionException extends RuntimeException {
+
+    private static final long serialVersionUID = 4602742888420994731L;
+
+    public CodecPreconditionException(String msg) {
+        super(msg);
+    }
+
+    public CodecPreconditionException(AugmentationPath path) {
+        super("Augmentation for path " + path + " is not implemented.");
+    }
+
+    public CodecPreconditionException(Extension extension) {
+        super("Extension " + extension.getClass() + " does not contain any known augmentation. " + extension);
+    }
+
+}
\ No newline at end of file
diff --git a/extension/openflowplugin-extension-eric/src/main/java/org/opendaylight/openflowplugin/extension/vendor/eric/convertor/match/Icmpv6NDOptionsTypeConvertor.java b/extension/openflowplugin-extension-eric/src/main/java/org/opendaylight/openflowplugin/extension/vendor/eric/convertor/match/Icmpv6NDOptionsTypeConvertor.java
new file mode 100644 (file)
index 0000000..a6987e1
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2019 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.extension.vendor.eric.convertor.match;
+
+import com.google.common.base.Optional;
+import org.opendaylight.openflowplugin.extension.api.ConvertorFromOFJava;
+import org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava;
+import org.opendaylight.openflowplugin.extension.api.ExtensionAugment;
+import org.opendaylight.openflowplugin.extension.api.path.MatchPath;
+import org.opendaylight.openflowplugin.extension.vendor.eric.convertor.CodecPreconditionException;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EricExpClass;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.Icmpv6NdOptionsType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.icmpv6.nd.options.type.grouping.Icmpv6NdOptionsTypeValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.oxm.container.match.entry.value.Icmpv6NdOptionsTypeCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.oxm.container.match.entry.value.Icmpv6NdOptionsTypeCaseValueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchNodesNodeTableFlow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchNodesNodeTableFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchNotifPacketIn;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchNotifPacketInBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchNotifSwitchFlowRemoved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchNotifSwitchFlowRemovedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchPacketInMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchPacketInMessageBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchRpcGetFlowStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchRpcGetFlowStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricOfIcmpv6NdOptionsTypeGrouping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.Icmpv6NdOptionsTypeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.eric.of.icmpv6.nd.options.type.grouping.EricOfIcmpv6NdOptionsType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.eric.of.icmpv6.nd.options.type.grouping.EricOfIcmpv6NdOptionsTypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.ExtensionKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+
+/**
+ * Convert to/from SAL flow model to openflowjava model for Icmpv6NDOptionsTypeCase.
+ */
+public class Icmpv6NDOptionsTypeConvertor implements ConvertorToOFJava<MatchEntry>,
+        ConvertorFromOFJava<MatchEntry, MatchPath> {
+
+    @Override
+    public ExtensionAugment<? extends Augmentation<Extension>> convert(MatchEntry input, MatchPath path) {
+        Icmpv6NdOptionsTypeCaseValue icmpv6NdOptionsTypeCaseValue
+                = (Icmpv6NdOptionsTypeCaseValue)input.getMatchEntryValue();
+        return resolveAugmentation(new EricOfIcmpv6NdOptionsTypeBuilder()
+                .setIcmpv6NdOptionsType(icmpv6NdOptionsTypeCaseValue.getIcmpv6NdOptionsTypeValues()
+                .getIcmpv6NdOptionsType()).build(), path, Icmpv6NdOptionsTypeKey.class);
+    }
+
+    @Override
+    public MatchEntry convert(Extension extension) {
+        Optional<EricOfIcmpv6NdOptionsTypeGrouping> matchGrouping = MatchUtil.ICMPV6_ND_OPTIONS_TYPE_RESOLVER
+                .getExtension(extension);
+        if (!matchGrouping.isPresent()) {
+            throw new CodecPreconditionException(extension);
+        }
+        short value = matchGrouping.get().getEricOfIcmpv6NdOptionsType().getIcmpv6NdOptionsType();
+        Icmpv6NdOptionsTypeCaseValueBuilder icmpv6NdOptionsTypeCaseValueBuilder
+                = new Icmpv6NdOptionsTypeCaseValueBuilder();
+        icmpv6NdOptionsTypeCaseValueBuilder.setIcmpv6NdOptionsTypeValues(new Icmpv6NdOptionsTypeValuesBuilder()
+                .setIcmpv6NdOptionsType(value).build());
+        return MatchUtil.createDefaultMatchEntryBuilder(Icmpv6NdOptionsType.class, EricExpClass.class,
+                icmpv6NdOptionsTypeCaseValueBuilder.build()).build();
+    }
+
+    private static ExtensionAugment<? extends Augmentation<Extension>> resolveAugmentation(
+            EricOfIcmpv6NdOptionsType value, MatchPath path, Class<? extends ExtensionKey> key) {
+        switch (path) {
+            case FLOWS_STATISTICS_UPDATE_MATCH:
+                return new ExtensionAugment<>(EricAugMatchNodesNodeTableFlow.class,
+                        new EricAugMatchNodesNodeTableFlowBuilder().setEricOfIcmpv6NdOptionsType(value).build(), key);
+            case FLOWS_STATISTICS_RPC_MATCH:
+                return new ExtensionAugment<>(EricAugMatchRpcGetFlowStats.class,
+                        new EricAugMatchRpcGetFlowStatsBuilder().setEricOfIcmpv6NdOptionsType(value).build(), key);
+            case PACKET_RECEIVED_MATCH:
+                return new ExtensionAugment<>(EricAugMatchNotifPacketIn.class, new EricAugMatchNotifPacketInBuilder()
+                        .setEricOfIcmpv6NdOptionsType(value).build(), key);
+            case SWITCH_FLOW_REMOVED_MATCH:
+                return new ExtensionAugment<>(EricAugMatchNotifSwitchFlowRemoved.class,
+                      new EricAugMatchNotifSwitchFlowRemovedBuilder().setEricOfIcmpv6NdOptionsType(value).build(), key);
+            case PACKET_IN_MESSAGE_MATCH:
+                return new ExtensionAugment<>(EricAugMatchPacketInMessage.class,
+                        new EricAugMatchPacketInMessageBuilder().setEricOfIcmpv6NdOptionsType(value).build(), key);
+            default:
+                throw new CodecPreconditionException(path);
+        }
+    }
+
+}
\ No newline at end of file
diff --git a/extension/openflowplugin-extension-eric/src/main/java/org/opendaylight/openflowplugin/extension/vendor/eric/convertor/match/Icmpv6NDReservedConvertor.java b/extension/openflowplugin-extension-eric/src/main/java/org/opendaylight/openflowplugin/extension/vendor/eric/convertor/match/Icmpv6NDReservedConvertor.java
new file mode 100644 (file)
index 0000000..c95c9eb
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2019 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.extension.vendor.eric.convertor.match;
+
+import com.google.common.base.Optional;
+import org.opendaylight.openflowplugin.extension.api.ConvertorFromOFJava;
+import org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava;
+import org.opendaylight.openflowplugin.extension.api.ExtensionAugment;
+import org.opendaylight.openflowplugin.extension.api.path.MatchPath;
+import org.opendaylight.openflowplugin.extension.vendor.eric.convertor.CodecPreconditionException;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EricExpClass;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.Icmpv6NdReserved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.icmpv6.nd.reserved.grouping.Icmpv6NdReservedValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.oxm.container.match.entry.value.Icmpv6NdReservedCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.oxm.container.match.entry.value.Icmpv6NdReservedCaseValueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchNodesNodeTableFlow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchNodesNodeTableFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchNotifPacketIn;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchNotifPacketInBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchNotifSwitchFlowRemoved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchNotifSwitchFlowRemovedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchPacketInMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchPacketInMessageBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchRpcGetFlowStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchRpcGetFlowStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricOfIcmpv6NdReservedGrouping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.Icmpv6NdReservedKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.eric.of.icmpv6.nd.reserved.grouping.EricOfIcmpv6NdReserved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.eric.of.icmpv6.nd.reserved.grouping.EricOfIcmpv6NdReservedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.ExtensionKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+
+/**
+ * Convert to/from SAL flow model to openflowjava model for Icmpv6NDReservedCase.
+ */
+public class Icmpv6NDReservedConvertor implements ConvertorToOFJava<MatchEntry>,
+        ConvertorFromOFJava<MatchEntry, MatchPath> {
+
+    @Override
+    public ExtensionAugment<? extends Augmentation<Extension>> convert(MatchEntry input, MatchPath path) {
+        Icmpv6NdReservedCaseValue icmpv6NdReservedCaseValue = (Icmpv6NdReservedCaseValue) input.getMatchEntryValue();
+        return resolveAugmentation(new EricOfIcmpv6NdReservedBuilder().setIcmpv6NdReserved(
+                icmpv6NdReservedCaseValue.getIcmpv6NdReservedValues().getIcmpv6NdReserved()).build(), path,
+                Icmpv6NdReservedKey.class);
+    }
+
+    @Override
+    public MatchEntry convert(Extension extension) {
+        Optional<EricOfIcmpv6NdReservedGrouping> matchGrouping
+                = MatchUtil.ICMPV6_ND_RESERVED_RESOLVER.getExtension(extension);
+        if (!matchGrouping.isPresent()) {
+            throw new CodecPreconditionException(extension);
+        }
+        long value = matchGrouping.get().getEricOfIcmpv6NdReserved().getIcmpv6NdReserved();
+        Icmpv6NdReservedCaseValueBuilder icmpv6NdReservedCaseValueBuilder = new Icmpv6NdReservedCaseValueBuilder();
+        icmpv6NdReservedCaseValueBuilder.setIcmpv6NdReservedValues(new Icmpv6NdReservedValuesBuilder()
+                .setIcmpv6NdReserved(value).build());
+        return MatchUtil.createDefaultMatchEntryBuilder(Icmpv6NdReserved.class, EricExpClass.class,
+                icmpv6NdReservedCaseValueBuilder.build()).build();
+    }
+
+    private static ExtensionAugment<? extends Augmentation<Extension>> resolveAugmentation(EricOfIcmpv6NdReserved value,
+            MatchPath path, Class<? extends ExtensionKey> key) {
+        switch (path) {
+            case FLOWS_STATISTICS_UPDATE_MATCH:
+                return new ExtensionAugment<>(EricAugMatchNodesNodeTableFlow.class,
+                        new EricAugMatchNodesNodeTableFlowBuilder().setEricOfIcmpv6NdReserved(value).build(), key);
+            case FLOWS_STATISTICS_RPC_MATCH:
+                return new ExtensionAugment<>(EricAugMatchRpcGetFlowStats.class,
+                        new EricAugMatchRpcGetFlowStatsBuilder().setEricOfIcmpv6NdReserved(value).build(), key);
+            case PACKET_RECEIVED_MATCH:
+                return new ExtensionAugment<>(EricAugMatchNotifPacketIn.class, new EricAugMatchNotifPacketInBuilder()
+                        .setEricOfIcmpv6NdReserved(value).build(), key);
+            case SWITCH_FLOW_REMOVED_MATCH:
+                return new ExtensionAugment<>(EricAugMatchNotifSwitchFlowRemoved.class,
+                        new EricAugMatchNotifSwitchFlowRemovedBuilder().setEricOfIcmpv6NdReserved(value).build(), key);
+            case PACKET_IN_MESSAGE_MATCH:
+                return new ExtensionAugment<>(EricAugMatchPacketInMessage.class,
+                        new EricAugMatchPacketInMessageBuilder().setEricOfIcmpv6NdReserved(value).build(), key);
+            default:
+                throw new CodecPreconditionException(path);
+        }
+    }
+
+}
\ No newline at end of file
diff --git a/extension/openflowplugin-extension-eric/src/main/java/org/opendaylight/openflowplugin/extension/vendor/eric/convertor/match/MatchUtil.java b/extension/openflowplugin-extension-eric/src/main/java/org/opendaylight/openflowplugin/extension/vendor/eric/convertor/match/MatchUtil.java
new file mode 100644 (file)
index 0000000..73d978e
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2019 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.extension.vendor.eric.convertor.match;
+
+import com.google.common.base.Joiner;
+import com.google.common.base.Splitter;
+import java.util.HashSet;
+import java.util.Set;
+import org.opendaylight.openflowplugin.extension.api.GroupingResolver;
+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.MatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.MatchEntryValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchNodesNodeTableFlow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchNodesNodeTableFlowApplyActionsSetField;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchNotifPacketIn;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchNotifSwitchFlowRemoved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchPacketInMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchRpcAddFlow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchRpcRemoveFlow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchRpcUpdateFlowOriginal;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchRpcUpdateFlowUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricOfIcmpv6NdOptionsTypeGrouping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricOfIcmpv6NdReservedGrouping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension;
+
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+
+/**
+ * Match utilities.
+ */
+public final class MatchUtil {
+    private static final Splitter SPLITTER = Splitter.on('.');
+    private static final Joiner JOINER = Joiner.on('.');
+    private static final Set<Class<? extends Augmentation<Extension>>> AUGMENTATIONS_OF_EXTENSION = new HashSet<>();
+    public static final GroupingResolver<EricOfIcmpv6NdReservedGrouping, Extension> ICMPV6_ND_RESERVED_RESOLVER
+            = new GroupingResolver<>(EricOfIcmpv6NdReservedGrouping.class);
+    public static final GroupingResolver<EricOfIcmpv6NdOptionsTypeGrouping, Extension> ICMPV6_ND_OPTIONS_TYPE_RESOLVER
+            = new GroupingResolver<>(EricOfIcmpv6NdOptionsTypeGrouping.class);
+
+    static {
+        AUGMENTATIONS_OF_EXTENSION.add(EricAugMatchRpcAddFlow.class);
+        AUGMENTATIONS_OF_EXTENSION.add(EricAugMatchRpcRemoveFlow.class);
+        AUGMENTATIONS_OF_EXTENSION.add(EricAugMatchRpcUpdateFlowOriginal.class);
+        AUGMENTATIONS_OF_EXTENSION.add(EricAugMatchRpcUpdateFlowUpdated.class);
+        AUGMENTATIONS_OF_EXTENSION.add(EricAugMatchNodesNodeTableFlow.class);
+        AUGMENTATIONS_OF_EXTENSION.add(EricAugMatchNotifSwitchFlowRemoved.class);
+        AUGMENTATIONS_OF_EXTENSION.add(EricAugMatchNotifPacketIn.class);
+        AUGMENTATIONS_OF_EXTENSION.add(EricAugMatchPacketInMessage.class);
+        AUGMENTATIONS_OF_EXTENSION.add(EricAugMatchNodesNodeTableFlowApplyActionsSetField.class);
+        ICMPV6_ND_RESERVED_RESOLVER.setAugmentations(AUGMENTATIONS_OF_EXTENSION);
+        ICMPV6_ND_OPTIONS_TYPE_RESOLVER.setAugmentations(AUGMENTATIONS_OF_EXTENSION);
+    }
+
+    private MatchUtil() {
+    }
+
+    public static MatchEntryBuilder createDefaultMatchEntryBuilder(Class<? extends MatchField> matchField,
+                                                                   Class<? extends OxmClassBase> oxmClass,
+                                                                   MatchEntryValue matchEntryValue) {
+        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+        matchEntryBuilder.setHasMask(false);
+        matchEntryBuilder.setOxmMatchField(matchField);
+        matchEntryBuilder.setOxmClass(oxmClass);
+        matchEntryBuilder.setMatchEntryValue(matchEntryValue);
+        return matchEntryBuilder;
+    }
+
+}
\ No newline at end of file
diff --git a/extension/openflowplugin-extension-eric/src/main/resources/org/opendaylight/blueprint/openflowplugin-extension-eric.xml b/extension/openflowplugin-extension-eric/src/main/resources/org/opendaylight/blueprint/openflowplugin-extension-eric.xml
new file mode 100644 (file)
index 0000000..a5f3734
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint odl:use-default-for-reference-types="true" xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
+ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0" xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+    <reference id="registratorProvider"
+               interface="org.opendaylight.openflowplugin.extension.api.OpenFlowPluginExtensionRegistratorProvider"/>
+    <bean id="ericExtensionProvider" destroy-method="close" class="org.opendaylight.openflowplugin.extension.vendor.eric.EricExtensionProvider">
+       <argument ref="registratorProvider"/>
+    </bean>
+</blueprint>
\ No newline at end of file
diff --git a/extension/openflowplugin-extension-eric/src/main/yang/openflowplugin-extension-eric-match.yang b/extension/openflowplugin-extension-eric/src/main/yang/openflowplugin-extension-eric-match.yang
new file mode 100644 (file)
index 0000000..9cc1255
--- /dev/null
@@ -0,0 +1,111 @@
+module openflowplugin-extension-eric-match {
+    yang-version 1;
+
+    namespace "urn:opendaylight:openflowplugin:extension:eric:match";
+    prefix "openflowplugin-eric-match";
+
+    import yang-ext {prefix ext; revision-date "2013-07-09";}
+    import flow-node-inventory {prefix fni; revision-date 2013-08-19; }
+    import opendaylight-inventory {prefix inv;revision-date "2013-08-19";}
+    import sal-flow {prefix sal-flow;revision-date "2013-08-19";}
+    import packet-processing {prefix sal-packet;revision-date "2013-07-09";}
+    import openflowplugin-extension-general {prefix ext-gen;revision-date "2014-07-14";}
+    import opendaylight-flow-statistics {prefix odl-flow-stats;revision-date "2013-08-19";}
+    import opendaylight-direct-statistics {prefix odl-direct-stats;revision-date "2016-05-11";}
+
+    description
+        "Eric openflow match extensions.";
+
+    revision "2018-07-30" {
+        description "Initial revision";
+    }
+
+    identity icmpv6-nd-reserved-key {
+        base ext-gen:extension-key;
+    }
+
+    identity icmpv6-nd-options-type-key {
+        base ext-gen:extension-key;
+    }
+
+    grouping eric-of-icmpv6-nd-reserved-grouping {
+        container eric-of-icmpv6-nd-reserved {
+            leaf icmpv6-nd-reserved {
+                type uint32;
+            }
+        }
+    }
+
+    grouping eric-of-icmpv6-nd-options-type-grouping {
+        container eric-of-icmpv6-nd-options-type {
+            leaf icmpv6-nd-options-type {
+                type uint8;
+            }
+        }
+    }
+
+    grouping all-matches-grouping {
+        uses eric-of-icmpv6-nd-reserved-grouping;
+        uses eric-of-icmpv6-nd-options-type-grouping;
+    }
+
+    // MATCH augmentations
+    // RPCS
+    augment "/sal-flow:add-flow/sal-flow:input/sal-flow:match/ext-gen:extension-list/ext-gen:extension" {
+        ext:augment-identifier "eric-aug-match-rpc-add-flow";
+        uses all-matches-grouping;
+    }
+    augment "/sal-flow:remove-flow/sal-flow:input/sal-flow:match/ext-gen:extension-list/ext-gen:extension" {
+        ext:augment-identifier "eric-aug-match-rpc-remove-flow";
+        uses all-matches-grouping;
+    }
+    augment "/sal-flow:update-flow/sal-flow:input/sal-flow:original-flow/sal-flow:match/ext-gen:extension-list/ext-gen:extension" {
+        ext:augment-identifier "eric-aug-match-rpc-update-flow-original";
+        uses all-matches-grouping;
+    }
+    augment "/sal-flow:update-flow/sal-flow:input/sal-flow:updated-flow/sal-flow:match/ext-gen:extension-list/ext-gen:extension" {
+        ext:augment-identifier "eric-aug-match-rpc-update-flow-updated";
+        uses all-matches-grouping;
+    }
+
+    // DATA
+    augment "/inv:nodes/inv:node/fni:table/fni:flow/fni:match/ext-gen:extension-list/ext-gen:extension" {
+        ext:augment-identifier "eric-aug-match-nodes-node-table-flow";
+        uses all-matches-grouping;
+    }
+    augment "/sal-packet:packet-in-message/sal-packet:match/ext-gen:extension-list/ext-gen:extension" {
+        ext:augment-identifier "eric-aug-match-packet-in-message";
+        uses all-matches-grouping;
+    }
+
+    // NOTIFICATIONS
+    augment "/sal-flow:switch-flow-removed/sal-flow:match/ext-gen:extension-list/ext-gen:extension" {
+        ext:augment-identifier "eric-aug-match-notif-switch-flow-removed";
+        uses all-matches-grouping;
+    }
+    augment "/sal-packet:packet-received/sal-packet:match/ext-gen:extension-list/ext-gen:extension" {
+        ext:augment-identifier "eric-aug-match-notif-packet-in";
+        uses all-matches-grouping;
+    }
+    augment "/odl-flow-stats:flows-statistics-update/odl-flow-stats:flow-and-statistics-map-list/odl-flow-stats:match/ext-gen:extension-list/ext-gen:extension" {
+        ext:augment-identifier "eric-aug-match-nodes-node-table-flow";
+        uses all-matches-grouping;
+    }
+    augment "/odl-direct-stats:get-flow-statistics/odl-direct-stats:output/odl-direct-stats:flow-and-statistics-map-list/odl-direct-stats:match/ext-gen:extension-list/ext-gen:extension" {
+        ext:augment-identifier "eric-aug-match-rpc-get-flow-stats";
+        uses all-matches-grouping;
+    }
+
+    // SetField augmentations
+
+    // DATA
+    augment "/inv:nodes/inv:node/fni:table/fni:flow/fni:instructions/fni:instruction/fni:instruction/fni:write-actions-case/fni:write-actions/fni:action/fni:action/fni:set-field-case/fni:set-field/ext-gen:extension-list/ext-gen:extension" {
+        ext:augment-identifier "eric-aug-match-nodes-node-table-flow-write-actions-set-field";
+        uses all-matches-grouping;
+    }
+
+    augment "/inv:nodes/inv:node/fni:table/fni:flow/fni:instructions/fni:instruction/fni:instruction/fni:apply-actions-case/fni:apply-actions/fni:action/fni:action/fni:set-field-case/fni:set-field/ext-gen:extension-list/ext-gen:extension" {
+        ext:augment-identifier "eric-aug-match-nodes-node-table-flow-apply-actions-set-field";
+        uses all-matches-grouping;
+    }
+}
\ No newline at end of file
diff --git a/extension/openflowplugin-extension-eric/src/test/java/org/opendaylight/openflowplugin/extension/vendor/eric/convertor/match/Icmpv6NDOptionsTypeConvertorTest.java b/extension/openflowplugin-extension-eric/src/test/java/org/opendaylight/openflowplugin/extension/vendor/eric/convertor/match/Icmpv6NDOptionsTypeConvertorTest.java
new file mode 100644 (file)
index 0000000..05b3b3d
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 2019 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.extension.vendor.eric.convertor.match;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+
+import java.util.Collections;
+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.runners.MockitoJUnitRunner;
+import org.opendaylight.openflowplugin.extension.api.ExtensionAugment;
+import org.opendaylight.openflowplugin.extension.api.GroupingLooseResolver;
+import org.opendaylight.openflowplugin.extension.api.path.MatchPath;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetField;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.icmpv6.nd.options.type.grouping.Icmpv6NdOptionsTypeValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.oxm.container.match.entry.value.Icmpv6NdOptionsTypeCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.oxm.container.match.entry.value.Icmpv6NdOptionsTypeCaseValueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchNodesNodeTableFlow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchNodesNodeTableFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchNotifPacketIn;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchNotifSwitchFlowRemoved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchRpcGetFlowStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.Icmpv6NdOptionsTypeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.eric.of.icmpv6.nd.options.type.grouping.EricOfIcmpv6NdOptionsTypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNodesNodeTableFlowWriteActionsSetField;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNodesNodeTableFlowWriteActionsSetFieldBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralExtensionListGrouping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.ExtensionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionListBuilder;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+
+/**
+ * Test for {@link Icmpv6NDOptionsTypeConvertor}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class Icmpv6NDOptionsTypeConvertorTest {
+
+    @Mock
+    private Extension extension;
+    @Mock
+    private MatchEntry matchEntry;
+
+    private Icmpv6NDOptionsTypeConvertor icmpv6NDOptionsTypeConvertor;
+
+    @Before
+    public void setUp()  {
+        final EricOfIcmpv6NdOptionsTypeBuilder ericOfIcmpv6NdOptionsTypeBuilder = new EricOfIcmpv6NdOptionsTypeBuilder()
+                .setIcmpv6NdOptionsType((short)1);
+        final EricAugMatchNodesNodeTableFlowBuilder ericAugMatchNotifUpdateFlowStatsBuilder =
+                new EricAugMatchNodesNodeTableFlowBuilder();
+        ericAugMatchNotifUpdateFlowStatsBuilder.setEricOfIcmpv6NdOptionsType(ericOfIcmpv6NdOptionsTypeBuilder.build());
+
+        final Augmentation<Extension> extensionAugmentation = ericAugMatchNotifUpdateFlowStatsBuilder.build();
+        when(extension.augmentation(Matchers.any()))
+                .thenReturn(extensionAugmentation);
+
+        icmpv6NDOptionsTypeConvertor = new Icmpv6NDOptionsTypeConvertor();
+    }
+
+    @Test
+    public void testConvert()  {
+        final MatchEntry converted = icmpv6NDOptionsTypeConvertor.convert(extension);
+        assertEquals(1, ((Icmpv6NdOptionsTypeCaseValue)converted.getMatchEntryValue())
+                .getIcmpv6NdOptionsTypeValues().getIcmpv6NdOptionsType().intValue());
+    }
+
+    @Test
+    public void testConvert1()  {
+        final Icmpv6NdOptionsTypeValuesBuilder icmpv6NdOptionsTypeValuesBuilder = new Icmpv6NdOptionsTypeValuesBuilder()
+                .setIcmpv6NdOptionsType((short)10);
+        final Icmpv6NdOptionsTypeCaseValueBuilder icmpv6NdOptionsTypeCaseValueBuilder
+                = new Icmpv6NdOptionsTypeCaseValueBuilder()
+                .setIcmpv6NdOptionsTypeValues(icmpv6NdOptionsTypeValuesBuilder.build());
+
+        final Icmpv6NdOptionsTypeCaseValue icmpv6NdOptionsTypeCaseValue = icmpv6NdOptionsTypeCaseValueBuilder.build();
+        when(matchEntry.getMatchEntryValue()).thenReturn(icmpv6NdOptionsTypeCaseValue);
+
+        final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment
+                = icmpv6NDOptionsTypeConvertor.convert(matchEntry, MatchPath.PACKET_RECEIVED_MATCH);
+        assertEquals(10, ((EricAugMatchNotifPacketIn) extensionAugment.getAugmentationObject())
+                .getEricOfIcmpv6NdOptionsType().getIcmpv6NdOptionsType().intValue());
+        assertEquals(extensionAugment.getKey(), Icmpv6NdOptionsTypeKey.class);
+
+        final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment1
+                = icmpv6NDOptionsTypeConvertor.convert(matchEntry, MatchPath.SWITCH_FLOW_REMOVED_MATCH);
+        assertEquals(10, ((EricAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject())
+                .getEricOfIcmpv6NdOptionsType() .getIcmpv6NdOptionsType().intValue());
+        assertEquals(extensionAugment.getKey(), Icmpv6NdOptionsTypeKey.class);
+
+        final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment2
+                = icmpv6NDOptionsTypeConvertor.convert(matchEntry, MatchPath.FLOWS_STATISTICS_UPDATE_MATCH);
+        assertEquals(10, ((EricAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject())
+                .getEricOfIcmpv6NdOptionsType().getIcmpv6NdOptionsType().intValue());
+        assertEquals(extensionAugment.getKey(), Icmpv6NdOptionsTypeKey.class);
+
+        final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment3
+                = icmpv6NDOptionsTypeConvertor.convert(matchEntry, MatchPath.FLOWS_STATISTICS_RPC_MATCH);
+        assertEquals(10, ((EricAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject())
+                .getEricOfIcmpv6NdOptionsType().getIcmpv6NdOptionsType().intValue());
+        assertEquals(extensionAugment.getKey(), Icmpv6NdOptionsTypeKey.class);
+    }
+
+    @Test
+    public void testSetFieldExtension()  {
+        GroupingLooseResolver<GeneralExtensionListGrouping> eqGroup =
+                new GroupingLooseResolver<>(GeneralExtensionListGrouping.class);
+        eqGroup.add(GeneralAugMatchNodesNodeTableFlowWriteActionsSetField.class);
+
+        ExtensionAugment<? extends Augmentation<Extension>> extensionMatch
+                =  new ExtensionAugment<>(EricAugMatchNodesNodeTableFlow.class,
+                new EricAugMatchNodesNodeTableFlowBuilder().setEricOfIcmpv6NdOptionsType(
+                        new EricOfIcmpv6NdOptionsTypeBuilder().setIcmpv6NdOptionsType((short)1).build()).build(),
+                Icmpv6NdOptionsTypeKey.class);
+
+        ExtensionListBuilder extListBld = null;
+        ExtensionBuilder extBld = new ExtensionBuilder();
+        extBld.addAugmentation(extensionMatch.getAugmentationClass(), extensionMatch.getAugmentationObject());
+
+        extListBld = new ExtensionListBuilder();
+        extListBld.setExtension(extBld.build());
+        extListBld.setExtensionKey(extensionMatch.getKey());
+
+        GeneralAugMatchNodesNodeTableFlowWriteActionsSetField ndOptionsTypeSetField =
+                 new GeneralAugMatchNodesNodeTableFlowWriteActionsSetFieldBuilder()
+                         .setExtensionList(Collections.singletonList(extListBld.build())).build();
+
+        SetFieldBuilder sb = new SetFieldBuilder();
+        SetField setField = sb.addAugmentation(GeneralAugMatchNodesNodeTableFlowWriteActionsSetField.class,
+                 ndOptionsTypeSetField).build();
+
+        Assert.assertEquals(Icmpv6NdOptionsTypeKey.class, eqGroup.getExtension(setField).get().getExtensionList().get(0)
+                 .getExtensionKey());
+    }
+
+}
\ No newline at end of file
diff --git a/extension/openflowplugin-extension-eric/src/test/java/org/opendaylight/openflowplugin/extension/vendor/eric/convertor/match/Icmpv6NDReservedConvertorTest.java b/extension/openflowplugin-extension-eric/src/test/java/org/opendaylight/openflowplugin/extension/vendor/eric/convertor/match/Icmpv6NDReservedConvertorTest.java
new file mode 100644 (file)
index 0000000..14fd3b0
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 2019 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.extension.vendor.eric.convertor.match;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+
+import java.util.Collections;
+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.runners.MockitoJUnitRunner;
+import org.opendaylight.openflowplugin.extension.api.ExtensionAugment;
+import org.opendaylight.openflowplugin.extension.api.GroupingLooseResolver;
+import org.opendaylight.openflowplugin.extension.api.path.MatchPath;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetField;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.icmpv6.nd.reserved.grouping.Icmpv6NdReservedValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.oxm.container.match.entry.value.Icmpv6NdReservedCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.oxm.container.match.entry.value.Icmpv6NdReservedCaseValueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchNodesNodeTableFlow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchNodesNodeTableFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchNotifPacketIn;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchNotifSwitchFlowRemoved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.EricAugMatchRpcGetFlowStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.Icmpv6NdReservedKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.eric.match.rev180730.eric.of.icmpv6.nd.reserved.grouping.EricOfIcmpv6NdReservedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNodesNodeTableFlowWriteActionsSetField;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNodesNodeTableFlowWriteActionsSetFieldBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralExtensionListGrouping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.ExtensionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionListBuilder;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+
+
+/**
+ * Test for {@link Icmpv6NDReservedConvertor}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class Icmpv6NDReservedConvertorTest {
+
+    @Mock
+    private Extension extension;
+    @Mock
+    private MatchEntry matchEntry;
+
+    private Icmpv6NDReservedConvertor icmpv6NDReservedConvertor;
+
+    @Before
+    public void setUp()  {
+        final EricOfIcmpv6NdReservedBuilder ericOfIcmpv6NdReservedBuilder = new EricOfIcmpv6NdReservedBuilder()
+                .setIcmpv6NdReserved(1L);
+        final EricAugMatchNodesNodeTableFlowBuilder ericAugMatchNotifUpdateFlowStatsBuilder =
+                new EricAugMatchNodesNodeTableFlowBuilder();
+        ericAugMatchNotifUpdateFlowStatsBuilder.setEricOfIcmpv6NdReserved(ericOfIcmpv6NdReservedBuilder.build());
+
+        final Augmentation<Extension> extensionAugmentation = ericAugMatchNotifUpdateFlowStatsBuilder.build();
+        when(extension.augmentation(Matchers.any()))
+            .thenReturn(extensionAugmentation);
+
+        icmpv6NDReservedConvertor = new Icmpv6NDReservedConvertor();
+    }
+
+    @Test
+    public void testConvert()  {
+        final MatchEntry converted = icmpv6NDReservedConvertor.convert(extension);
+        assertEquals(1, ((Icmpv6NdReservedCaseValue)converted.getMatchEntryValue())
+                .getIcmpv6NdReservedValues().getIcmpv6NdReserved().intValue());
+    }
+
+    @Test
+    public void testConvert1()  {
+        final Icmpv6NdReservedValuesBuilder icmpv6NdReservedValuesBuilder = new Icmpv6NdReservedValuesBuilder()
+                .setIcmpv6NdReserved(10L);
+        final Icmpv6NdReservedCaseValueBuilder icmpv6NdReservedCaseValueBuilder = new Icmpv6NdReservedCaseValueBuilder()
+                .setIcmpv6NdReservedValues(icmpv6NdReservedValuesBuilder.build());
+
+        final Icmpv6NdReservedCaseValue icmpv6NdReservedCaseValue = icmpv6NdReservedCaseValueBuilder.build();
+        when(matchEntry.getMatchEntryValue()).thenReturn(icmpv6NdReservedCaseValue);
+
+        final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment
+                = icmpv6NDReservedConvertor.convert(matchEntry, MatchPath.PACKET_RECEIVED_MATCH);
+        assertEquals(10, ((EricAugMatchNotifPacketIn) extensionAugment.getAugmentationObject())
+                .getEricOfIcmpv6NdReserved().getIcmpv6NdReserved().intValue());
+        assertEquals(extensionAugment.getKey(), Icmpv6NdReservedKey.class);
+
+        final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment1
+                = icmpv6NDReservedConvertor.convert(matchEntry, MatchPath.SWITCH_FLOW_REMOVED_MATCH);
+        assertEquals(10, ((EricAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject())
+                .getEricOfIcmpv6NdReserved().getIcmpv6NdReserved().intValue());
+        assertEquals(extensionAugment.getKey(), Icmpv6NdReservedKey.class);
+
+        final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment2
+                = icmpv6NDReservedConvertor.convert(matchEntry, MatchPath.FLOWS_STATISTICS_UPDATE_MATCH);
+        assertEquals(10, ((EricAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject())
+                .getEricOfIcmpv6NdReserved().getIcmpv6NdReserved().intValue());
+        assertEquals(extensionAugment.getKey(), Icmpv6NdReservedKey.class);
+
+        final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment3
+               = icmpv6NDReservedConvertor.convert(matchEntry, MatchPath.FLOWS_STATISTICS_RPC_MATCH);
+        assertEquals(10, ((EricAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject())
+                .getEricOfIcmpv6NdReserved().getIcmpv6NdReserved().intValue());
+        assertEquals(extensionAugment.getKey(), Icmpv6NdReservedKey.class);
+    }
+
+    @Test
+    public void testSetFieldExtension()  {
+        GroupingLooseResolver<GeneralExtensionListGrouping> eqGroup =
+                new GroupingLooseResolver<>(GeneralExtensionListGrouping.class);
+        eqGroup.add(GeneralAugMatchNodesNodeTableFlowWriteActionsSetField.class);
+
+        ExtensionAugment<? extends Augmentation<Extension>> extensionMatch
+                =  new ExtensionAugment<>(EricAugMatchNodesNodeTableFlow.class,
+                new EricAugMatchNodesNodeTableFlowBuilder().setEricOfIcmpv6NdReserved(
+                        new EricOfIcmpv6NdReservedBuilder().setIcmpv6NdReserved(1L).build()).build(),
+                Icmpv6NdReservedKey.class);
+
+        ExtensionListBuilder extListBld = null;
+        ExtensionBuilder extBld = new ExtensionBuilder();
+        extBld.addAugmentation(extensionMatch.getAugmentationClass(), extensionMatch.getAugmentationObject());
+
+        extListBld = new ExtensionListBuilder();
+        extListBld.setExtension(extBld.build());
+        extListBld.setExtensionKey(extensionMatch.getKey());
+
+        GeneralAugMatchNodesNodeTableFlowWriteActionsSetField ndReservedSetField =
+                 new GeneralAugMatchNodesNodeTableFlowWriteActionsSetFieldBuilder()
+                         .setExtensionList(Collections.singletonList(extListBld.build())).build();
+
+        SetFieldBuilder sb = new SetFieldBuilder();
+        SetField setField = sb.addAugmentation(GeneralAugMatchNodesNodeTableFlowWriteActionsSetField.class,
+                ndReservedSetField).build();
+
+        Assert.assertEquals(Icmpv6NdReservedKey.class, eqGroup.getExtension(setField).get().getExtensionList().get(0)
+                .getExtensionKey());
+    }
+
+}
\ No newline at end of file
index d549884a673b07b40a414b08045772c795cf5f13..04407e274afdbde491aa1d13eecb3e304c440ffc 100644 (file)
@@ -17,6 +17,8 @@
         <module>openflowplugin-extension-api</module>
         <module>openflowplugin-extension-nicira</module>
         <module>openflowplugin-extension-onf</module>
+        <module>openflowjava-extension-eric</module>
+        <module>openflowplugin-extension-eric</module>
         <module>test-extension</module>
         <module>features-extension-aggregator</module>
     </modules>
index 36dd62b7e2814f17a7738bb47ff5d4bdb7377585..fad19022fcb02fa66a0514696522503db625e082 100644 (file)
             <groupId>org.opendaylight.openflowplugin</groupId>
             <artifactId>openflowplugin-extension-nicira</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.openflowplugin</groupId>
+            <artifactId>openflowplugin-extension-eric</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.opendaylight.openflowplugin</groupId>
             <artifactId>openflowplugin-extension-api</artifactId>
             <groupId>org.opendaylight.openflowplugin</groupId>
             <artifactId>openflowjava-extension-nicira</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.openflowplugin</groupId>
+            <artifactId>openflowjava-extension-eric</artifactId>
+        </dependency>
         <dependency>
             <!-- configSubsystem yang should be moved to API and this would be doomed for removal -->
             <groupId>org.opendaylight.openflowplugin</groupId>
index a093a56e0aae54447a62a875731a106b8910dbe3..f7bcf1a077e44adff63c4c8b47fa5fa015f516bd 100644 (file)
         description "Match class for backward compatibility with NXM";
         base oxm-class-base;
     }
+    identity eric-exp-class {
+        description "Ericsson experimenter class for openflow";
+        base oxm-class-base;
+    }
     identity openflow-basic-class {
         description "Basic class for OpenFlow";
         base oxm-class-base;
                     }
                 }
             }
+            case icmpv6-nd-reserved-case {
+                container icmpv6-nd-reserved {
+                    leaf icmpv6-nd-reserved {
+                        type uint32;
+                    }
+                }
+            }
+            case icmpv6-nd-options-type-case {
+                container icmpv6-nd-options-type {
+                    leaf icmpv6-nd-options-type {
+                        type uint8;
+                    }
+                }
+            }
             case arp-spa-case {
                 container arp-spa {
                     leaf ipv4-address {