Merge "Refactor nsh fields to new encoding"
authorAnil Vishnoi <vishnoianil@gmail.com>
Wed, 25 Jul 2018 20:03:54 +0000 (20:03 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 25 Jul 2018 20:03:54 +0000 (20:03 +0000)
39 files changed:
extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractNshcCodec.java [new file with mode: 0644]
extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NshMdtypeCodec.java
extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NshNpCodec.java
extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Nshc1Codec.java
extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Nshc2Codec.java
extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Nshc3Codec.java
extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Nshc4Codec.java
extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NsiCodec.java
extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NspCodec.java
extension/openflowjava-extension-nicira/src/main/yang/nicira-match.yang
extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/NiciraExtensionsRegistratorTest.java
extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/AbstractNshcCodecTest.java [new file with mode: 0644]
extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NshMdtypeCodecTest.java [new file with mode: 0644]
extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NshNpCodecTest.java [new file with mode: 0644]
extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/Nshc1CodecTest.java [deleted file]
extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/Nshc2CodecTest.java [deleted file]
extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/Nshc3CodecTest.java [deleted file]
extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/Nshc4CodecTest.java [deleted file]
extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NsiCodecTest.java
extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NspCodecTest.java
extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/RegLoad2Convertor.java
extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshMdtypeConvertor.java
extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshNpConvertor.java
extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc1Convertor.java
extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc2Convertor.java
extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc3Convertor.java
extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc4Convertor.java
extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NsiConvertor.java
extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NspConvertor.java
extension/openflowplugin-extension-nicira/src/main/yang/openflowplugin-extension-nicira-match.yang
extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/RegLoad2ConvertorTest.java
extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshMdtypeConvertorTest.java [new file with mode: 0644]
extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshNpConvertorTest.java [new file with mode: 0644]
extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc1ConvertorTest.java
extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc2ConvertorTest.java
extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc3ConvertorTest.java
extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc4ConvertorTest.java
extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NsiConvertorTest.java
extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NspConvertorTest.java

diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractNshcCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractNshcCodec.java
new file mode 100644 (file)
index 0000000..527475e
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2018 SUSE LINUX GmbH.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.nx.codec.match;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.nx.api.NiciraConstants;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshcCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshcCaseValueBuilder;
+
+public abstract class AbstractNshcCodec extends AbstractExperimenterMatchCodec {
+
+    private static final int VALUE_LENGTH = EncodeConstants.SIZE_OF_INT_IN_BYTES;
+
+    @Override
+    protected void serializeValue(NxExpMatchEntryValue value, boolean hasMask, ByteBuf outBuffer) {
+        NshcCaseValue nshcCaseValue = (NshcCaseValue) value;
+        outBuffer.writeInt(nshcCaseValue.getNshc().intValue());
+        if (hasMask) {
+            outBuffer.writeInt(nshcCaseValue.getMask().intValue());
+        }
+    }
+
+    @Override
+    protected NxExpMatchEntryValue deserializeValue(ByteBuf message, boolean hasMask) {
+        Long nshc = message.readUnsignedInt();
+        Long mask = hasMask ? message.readUnsignedInt() : null;
+        return new NshcCaseValueBuilder().setNshc(nshc).setMask(mask).build();
+    }
+
+    @Override
+    protected long getExperimenterId() {
+        return NiciraConstants.NX_NSH_VENDOR_ID;
+    }
+
+    @Override
+    public int getValueLength() {
+        return VALUE_LENGTH;
+    }
+
+}
index ed1c74e38362817e29a824c46bd01d2cd4c36c54..0d916dc7e91f13dd7166cf3a1c1beaf20504a945 100644 (file)
@@ -9,45 +9,46 @@
 package org.opendaylight.openflowjava.nx.codec.match;
 
 import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.nx.api.NiciraConstants;
 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey;
 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
-import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
-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.nx.match.rev140421.NxmNxNshMdtype;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsh.mdtype.grouping.NshMdtypeValues;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsh.mdtype.grouping.NshMdtypeValuesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.NshMdtypeCaseValue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.NshMdtypeCaseValueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshMdtypeCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshMdtypeCaseValueBuilder;
 
-public class NshMdtypeCodec extends AbstractMatchCodec {
+public class NshMdtypeCodec extends AbstractExperimenterMatchCodec {
 
-    private static final int VALUE_LENGTH = 1;
-    private static final int NXM_FIELD_CODE = 119;
-    public static final MatchEntrySerializerKey<Nxm1Class, NxmNxNshMdtype> SERIALIZER_KEY =
-            new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNshMdtype.class);
-    public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
-            EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE);
+    private static final int VALUE_LENGTH = EncodeConstants.SIZE_OF_BYTE_IN_BYTES;
+    private static final int NXM_FIELD_CODE = 2;
+    public static final MatchEntrySerializerKey<ExperimenterClass, NxmNxNshMdtype> SERIALIZER_KEY =
+            createSerializerKey(
+                    EncodeConstants.OF13_VERSION_ID,
+                    NiciraConstants.NX_NSH_VENDOR_ID,
+                    NxmNxNshMdtype.class);
+    public static final MatchEntryDeserializerKey DESERIALIZER_KEY =
+            createDeserializerKey(
+                    EncodeConstants.OF13_VERSION_ID,
+                    NiciraConstants.NX_NSH_VENDOR_ID,
+                    NXM_FIELD_CODE);
 
     @Override
-    public void serialize(MatchEntry input, ByteBuf outBuffer) {
-        serializeHeader(input, outBuffer);
-        NshMdtypeCaseValue nshMdtypeCaseValue = (NshMdtypeCaseValue) input.getMatchEntryValue();
-        outBuffer.writeByte(nshMdtypeCaseValue.getNshMdtypeValues().getValue());
+    protected void serializeValue(NxExpMatchEntryValue value, boolean hasMask, ByteBuf outBuffer) {
+        NshMdtypeCaseValue nshMdtypeCaseValue = (NshMdtypeCaseValue) value;
+        NshMdtypeValues nshMdtypeValues = nshMdtypeCaseValue.getNshMdtypeValues();
+        outBuffer.writeByte(nshMdtypeValues.getValue());
     }
 
     @Override
-    public MatchEntry deserialize(ByteBuf message) {
-        MatchEntryBuilder matchEntriesBuilder = deserializeHeaderToBuilder(message);
-        NshMdtypeCaseValueBuilder nshMdtypeCaseValueBuilder = new NshMdtypeCaseValueBuilder();
-        nshMdtypeCaseValueBuilder.setNshMdtypeValues(new NshMdtypeValuesBuilder()
-                .setValue(message.readUnsignedByte()).build());
-        matchEntriesBuilder.setMatchEntryValue(nshMdtypeCaseValueBuilder.build());
-        matchEntriesBuilder.setHasMask(false);
-        return matchEntriesBuilder.build();
+    protected NxExpMatchEntryValue deserializeValue(ByteBuf message, boolean hasMask) {
+        Short value = message.readUnsignedByte();
+        NshMdtypeValues nshMdtypeValues = new NshMdtypeValuesBuilder().setValue(value).build();
+        return new NshMdtypeCaseValueBuilder().setNshMdtypeValues(nshMdtypeValues).build();
     }
 
     @Override
@@ -56,8 +57,8 @@ public class NshMdtypeCodec extends AbstractMatchCodec {
     }
 
     @Override
-    public int getOxmClassCode() {
-        return OxmMatchConstants.NXM_1_CLASS;
+    protected long getExperimenterId() {
+        return NiciraConstants.NX_NSH_VENDOR_ID;
     }
 
     @Override
@@ -70,8 +71,4 @@ public class NshMdtypeCodec extends AbstractMatchCodec {
         return NxmNxNshMdtype.class;
     }
 
-    @Override
-    public Class<? extends OxmClassBase> getOxmClass() {
-        return Nxm1Class.class;
-    }
 }
index ca6f81e23ffcd7a62e1c5688846fb5cd78c62963..bcc3cced1839ad8c640e9b40d2ba74bb44d99fff 100644 (file)
@@ -9,44 +9,46 @@
 package org.opendaylight.openflowjava.nx.codec.match;
 
 import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.nx.api.NiciraConstants;
 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey;
 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
-import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
-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.nx.match.rev140421.NxmNxNshNp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsh.np.grouping.NshNpValues;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsh.np.grouping.NshNpValuesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.NshNpCaseValue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.NshNpCaseValueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshNpCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshNpCaseValueBuilder;
 
-public class NshNpCodec extends AbstractMatchCodec {
+public class NshNpCodec extends AbstractExperimenterMatchCodec {
 
-    private static final int VALUE_LENGTH = 1;
-    private static final int NXM_FIELD_CODE = 120;
-    public static final MatchEntrySerializerKey<Nxm1Class, NxmNxNshNp> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
-            EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNshNp.class);
-    public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
-            EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE);
+    private static final int VALUE_LENGTH = EncodeConstants.SIZE_OF_BYTE_IN_BYTES;
+    private static final int NXM_FIELD_CODE = 3;
+    public static final MatchEntrySerializerKey<ExperimenterClass, NxmNxNshNp> SERIALIZER_KEY =
+            createSerializerKey(
+                    EncodeConstants.OF13_VERSION_ID,
+                    NiciraConstants.NX_NSH_VENDOR_ID,
+                    NxmNxNshNp.class);
+    public static final MatchEntryDeserializerKey DESERIALIZER_KEY =
+            createDeserializerKey(
+                    EncodeConstants.OF13_VERSION_ID,
+                    NiciraConstants.NX_NSH_VENDOR_ID,
+                    NXM_FIELD_CODE);
 
     @Override
-    public void serialize(MatchEntry input, ByteBuf outBuffer) {
-        serializeHeader(input, outBuffer);
-        NshNpCaseValue nshNpCaseValue = ((NshNpCaseValue) input.getMatchEntryValue());
-        outBuffer.writeByte(nshNpCaseValue.getNshNpValues().getValue());
+    protected void serializeValue(NxExpMatchEntryValue value, boolean hasMask, ByteBuf outBuffer) {
+        NshNpCaseValue nshNpCaseValue = (NshNpCaseValue) value;
+        NshNpValues nshNpValues = nshNpCaseValue.getNshNpValues();
+        outBuffer.writeByte(nshNpValues.getValue());
     }
 
     @Override
-    public MatchEntry deserialize(ByteBuf message) {
-        MatchEntryBuilder matchEntriesBuilder = deserializeHeaderToBuilder(message);
-        NshNpCaseValueBuilder nshNpCaseValueBuilder = new NshNpCaseValueBuilder();
-        nshNpCaseValueBuilder.setNshNpValues(new NshNpValuesBuilder().setValue(message.readUnsignedByte()).build());
-        matchEntriesBuilder.setMatchEntryValue(nshNpCaseValueBuilder.build());
-        matchEntriesBuilder.setHasMask(false);
-        return matchEntriesBuilder.build();
+    protected NxExpMatchEntryValue deserializeValue(ByteBuf message, boolean hasMask) {
+        Short value = message.readUnsignedByte();
+        NshNpValues nshNpValues = new NshNpValuesBuilder().setValue(value).build();
+        return new NshNpCaseValueBuilder().setNshNpValues(nshNpValues).build();
     }
 
     @Override
@@ -55,8 +57,8 @@ public class NshNpCodec extends AbstractMatchCodec {
     }
 
     @Override
-    public int getOxmClassCode() {
-        return OxmMatchConstants.NXM_1_CLASS;
+    protected long getExperimenterId() {
+        return NiciraConstants.NX_NSH_VENDOR_ID;
     }
 
     @Override
@@ -68,9 +70,4 @@ public class NshNpCodec extends AbstractMatchCodec {
     public Class<? extends MatchField> getNxmField() {
         return NxmNxNshNp.class;
     }
-
-    @Override
-    public Class<? extends OxmClassBase> getOxmClass() {
-        return Nxm1Class.class;
-    }
 }
index 482b4d7a5b4b1da84b998ac7ab87b2be9c66ae02..3aaf771f85569acb0ed3147052c40280f90971d7 100644 (file)
@@ -8,70 +8,35 @@
 
 package org.opendaylight.openflowjava.nx.codec.match;
 
-import io.netty.buffer.ByteBuf;
-
+import org.opendaylight.openflowjava.nx.api.NiciraConstants;
 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey;
 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
-import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
-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.nx.match.rev140421.NxmNxNshc1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nshc._1.grouping.Nshc1ValuesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc1CaseValue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc1CaseValueBuilder;
 
-public class Nshc1Codec extends AbstractMatchCodec {
+public class Nshc1Codec extends AbstractNshcCodec {
 
-    private static final int VALUE_LENGTH = 4;
-    private static final int NXM_FIELD_CODE = 115;
-    public static final MatchEntrySerializerKey<Nxm1Class, NxmNxNshc1> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
-            EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNshc1.class);
-    public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
-            EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE);
-
-    @Override
-    public void serialize(MatchEntry input, ByteBuf outBuffer) {
-        serializeHeader(input, outBuffer);
-        Nshc1CaseValue csc1CaseValue = ((Nshc1CaseValue) input.getMatchEntryValue());
-        outBuffer.writeInt(csc1CaseValue.getNshc1Values().getNshc().intValue());
-    }
-
-    @Override
-    public MatchEntry deserialize(ByteBuf message) {
-        MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message);
-        Nshc1CaseValueBuilder nsc1CaseValueBuilder = new Nshc1CaseValueBuilder();
-        nsc1CaseValueBuilder.setNshc1Values(new Nshc1ValuesBuilder().setNshc(message.readUnsignedInt()).build());
-        matchEntryBuilder.setMatchEntryValue(nsc1CaseValueBuilder.build());
-
-        return matchEntryBuilder.build();
-    }
+    private static final int NXM_FIELD_CODE = 6;
+    public static final MatchEntrySerializerKey<ExperimenterClass, NxmNxNshc1> SERIALIZER_KEY =
+            createSerializerKey(
+                    EncodeConstants.OF13_VERSION_ID,
+                    NiciraConstants.NX_NSH_VENDOR_ID,
+                    NxmNxNshc1.class);
+    public static final MatchEntryDeserializerKey DESERIALIZER_KEY =
+            createDeserializerKey(
+                    EncodeConstants.OF13_VERSION_ID,
+                    NiciraConstants.NX_NSH_VENDOR_ID,
+                    NXM_FIELD_CODE);
 
     @Override
     public int getNxmFieldCode() {
         return NXM_FIELD_CODE;
     }
 
-    @Override
-    public int getOxmClassCode() {
-        return OxmMatchConstants.NXM_1_CLASS;
-    }
-
-    @Override
-    public int getValueLength() {
-        return VALUE_LENGTH;
-    }
-
     @Override
     public Class<? extends MatchField> getNxmField() {
         return NxmNxNshc1.class;
     }
-
-    @Override
-    public Class<? extends OxmClassBase> getOxmClass() {
-        return Nxm1Class.class;
-    }
 }
index 5e8821db0bf557092d284d1247c14642ef2ce365..01f3c6b2ccb82ea54f685267f6d0c5523703dbf2 100644 (file)
@@ -8,70 +8,35 @@
 
 package org.opendaylight.openflowjava.nx.codec.match;
 
-import io.netty.buffer.ByteBuf;
-
+import org.opendaylight.openflowjava.nx.api.NiciraConstants;
 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey;
 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
-import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
-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.nx.match.rev140421.NxmNxNshc2;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nshc._2.grouping.Nshc2ValuesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc2CaseValue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc2CaseValueBuilder;
 
-public class Nshc2Codec extends AbstractMatchCodec {
+public class Nshc2Codec extends AbstractNshcCodec {
 
-    private static final int VALUE_LENGTH = 4;
-    private static final int NXM_FIELD_CODE = 116;
-    public static final MatchEntrySerializerKey<Nxm1Class, NxmNxNshc2> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
-            EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNshc2.class);
-    public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
-            EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE);
-
-    @Override
-    public void serialize(MatchEntry input, ByteBuf outBuffer) {
-        serializeHeader(input, outBuffer);
-        Nshc2CaseValue csc1CaseValue = ((Nshc2CaseValue) input.getMatchEntryValue());
-        outBuffer.writeInt(csc1CaseValue.getNshc2Values().getNshc().intValue());
-    }
-
-    @Override
-    public MatchEntry deserialize(ByteBuf message) {
-        MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message);
-        Nshc2CaseValueBuilder nsc2CaseValueBuilder = new Nshc2CaseValueBuilder();
-        nsc2CaseValueBuilder.setNshc2Values(new Nshc2ValuesBuilder().setNshc(message.readUnsignedInt()).build());
-        matchEntryBuilder.setMatchEntryValue(nsc2CaseValueBuilder.build());
-
-        return matchEntryBuilder.build();
-    }
+    private static final int NXM_FIELD_CODE = 7;
+    public static final MatchEntrySerializerKey<ExperimenterClass, NxmNxNshc2> SERIALIZER_KEY =
+            createSerializerKey(
+                    EncodeConstants.OF13_VERSION_ID,
+                    NiciraConstants.NX_NSH_VENDOR_ID,
+                    NxmNxNshc2.class);
+    public static final MatchEntryDeserializerKey DESERIALIZER_KEY =
+            createDeserializerKey(
+                    EncodeConstants.OF13_VERSION_ID,
+                    NiciraConstants.NX_NSH_VENDOR_ID,
+                    NXM_FIELD_CODE);
 
     @Override
     public int getNxmFieldCode() {
         return NXM_FIELD_CODE;
     }
 
-    @Override
-    public int getOxmClassCode() {
-        return OxmMatchConstants.NXM_1_CLASS;
-    }
-
-    @Override
-    public int getValueLength() {
-        return VALUE_LENGTH;
-    }
-
     @Override
     public Class<? extends MatchField> getNxmField() {
         return NxmNxNshc2.class;
     }
-
-    @Override
-    public Class<? extends OxmClassBase> getOxmClass() {
-        return Nxm1Class.class;
-    }
-}
+}
\ No newline at end of file
index cea6e09fa4b5e0d31da3bf1d6b0ffa50cce184d8..8f939fef2a680d85446d344b6bbc0257310c512f 100644 (file)
@@ -8,70 +8,35 @@
 
 package org.opendaylight.openflowjava.nx.codec.match;
 
-import io.netty.buffer.ByteBuf;
-
+import org.opendaylight.openflowjava.nx.api.NiciraConstants;
 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey;
 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
-import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
-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.nx.match.rev140421.NxmNxNshc3;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nshc._3.grouping.Nshc3ValuesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc3CaseValue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc3CaseValueBuilder;
 
-public class Nshc3Codec extends AbstractMatchCodec {
+public class Nshc3Codec extends AbstractNshcCodec {
 
-    private static final int VALUE_LENGTH = 4;
-    private static final int NXM_FIELD_CODE = 117;
-    public static final MatchEntrySerializerKey<Nxm1Class, NxmNxNshc3> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
-            EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNshc3.class);
-    public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
-            EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE);
-
-    @Override
-    public void serialize(MatchEntry input, ByteBuf outBuffer) {
-        serializeHeader(input, outBuffer);
-        Nshc3CaseValue csc1CaseValue = ((Nshc3CaseValue) input.getMatchEntryValue());
-        outBuffer.writeInt(csc1CaseValue.getNshc3Values().getNshc().intValue());
-    }
-
-    @Override
-    public MatchEntry deserialize(ByteBuf message) {
-        MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message);
-        Nshc3CaseValueBuilder nsc3CaseValueBuilder = new Nshc3CaseValueBuilder();
-        nsc3CaseValueBuilder.setNshc3Values(new Nshc3ValuesBuilder().setNshc(message.readUnsignedInt()).build());
-        matchEntryBuilder.setMatchEntryValue(nsc3CaseValueBuilder.build());
-
-        return matchEntryBuilder.build();
-    }
+    private static final int NXM_FIELD_CODE = 8;
+    public static final MatchEntrySerializerKey<ExperimenterClass, NxmNxNshc3> SERIALIZER_KEY =
+            createSerializerKey(
+                    EncodeConstants.OF13_VERSION_ID,
+                    NiciraConstants.NX_NSH_VENDOR_ID,
+                    NxmNxNshc3.class);
+    public static final MatchEntryDeserializerKey DESERIALIZER_KEY =
+            createDeserializerKey(
+                    EncodeConstants.OF13_VERSION_ID,
+                    NiciraConstants.NX_NSH_VENDOR_ID,
+                    NXM_FIELD_CODE);
 
     @Override
     public int getNxmFieldCode() {
         return NXM_FIELD_CODE;
     }
 
-    @Override
-    public int getOxmClassCode() {
-        return OxmMatchConstants.NXM_1_CLASS;
-    }
-
-    @Override
-    public int getValueLength() {
-        return VALUE_LENGTH;
-    }
-
     @Override
     public Class<? extends MatchField> getNxmField() {
         return NxmNxNshc3.class;
     }
-
-    @Override
-    public Class<? extends OxmClassBase> getOxmClass() {
-        return Nxm1Class.class;
-    }
 }
index 2a78165093e7d2482a27ae262e3396751643e58b..d4d33fa87174a7cccdd529b98ff21749961561e2 100644 (file)
@@ -8,70 +8,35 @@
 
 package org.opendaylight.openflowjava.nx.codec.match;
 
-import io.netty.buffer.ByteBuf;
-
+import org.opendaylight.openflowjava.nx.api.NiciraConstants;
 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey;
 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
-import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
-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.nx.match.rev140421.NxmNxNshc4;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nshc._4.grouping.Nshc4ValuesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc4CaseValue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc4CaseValueBuilder;
 
-public class Nshc4Codec extends AbstractMatchCodec {
+public class Nshc4Codec extends AbstractNshcCodec {
 
-    private static final int VALUE_LENGTH = 4;
-    private static final int NXM_FIELD_CODE = 118;
-    public static final MatchEntrySerializerKey<Nxm1Class, NxmNxNshc4> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
-            EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNshc4.class);
-    public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
-            EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE);
-
-    @Override
-    public void serialize(MatchEntry input, ByteBuf outBuffer) {
-        serializeHeader(input, outBuffer);
-        Nshc4CaseValue csc1CaseValue = ((Nshc4CaseValue) input.getMatchEntryValue());
-        outBuffer.writeInt(csc1CaseValue.getNshc4Values().getNshc().intValue());
-    }
-
-    @Override
-    public MatchEntry deserialize(ByteBuf message) {
-        MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message);
-        Nshc4CaseValueBuilder nsc4CaseValueBuilder = new Nshc4CaseValueBuilder();
-        nsc4CaseValueBuilder.setNshc4Values(new Nshc4ValuesBuilder().setNshc(message.readUnsignedInt()).build());
-        matchEntryBuilder.setMatchEntryValue(nsc4CaseValueBuilder.build());
-
-        return matchEntryBuilder.build();
-    }
+    private static final int NXM_FIELD_CODE = 9;
+    public static final MatchEntrySerializerKey<ExperimenterClass, NxmNxNshc4> SERIALIZER_KEY =
+            createSerializerKey(
+                    EncodeConstants.OF13_VERSION_ID,
+                    NiciraConstants.NX_NSH_VENDOR_ID,
+                    NxmNxNshc4.class);
+    public static final MatchEntryDeserializerKey DESERIALIZER_KEY =
+            createDeserializerKey(
+                    EncodeConstants.OF13_VERSION_ID,
+                    NiciraConstants.NX_NSH_VENDOR_ID,
+                    NXM_FIELD_CODE);
 
     @Override
     public int getNxmFieldCode() {
         return NXM_FIELD_CODE;
     }
 
-    @Override
-    public int getOxmClassCode() {
-        return OxmMatchConstants.NXM_1_CLASS;
-    }
-
-    @Override
-    public int getValueLength() {
-        return VALUE_LENGTH;
-    }
-
     @Override
     public Class<? extends MatchField> getNxmField() {
         return NxmNxNshc4.class;
     }
-
-    @Override
-    public Class<? extends OxmClassBase> getOxmClass() {
-        return Nxm1Class.class;
-    }
 }
index 823f7de532a4ace4a1f8cb09ecb0796f89b7e73b..3673d2fb95018b1b747bbb2ad21cd26662aaf4da 100644 (file)
@@ -9,44 +9,50 @@
 package org.opendaylight.openflowjava.nx.codec.match;
 
 import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.nx.api.NiciraConstants;
 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey;
 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
-import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
-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.nx.match.rev140421.NxmNxNsi;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsi.grouping.NsiValues;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsi.grouping.NsiValuesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.NsiCaseValue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.NsiCaseValueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NsiCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NsiCaseValueBuilder;
 
-public class NsiCodec extends AbstractMatchCodec {
+public class NsiCodec extends AbstractExperimenterMatchCodec {
 
-    private static final int VALUE_LENGTH = 1;
-    private static final int NXM_FIELD_CODE = 114;
-    public static final MatchEntrySerializerKey<Nxm1Class, NxmNxNsi> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
-            EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNsi.class);
-    public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
-            EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE);
+    private static final int VALUE_LENGTH = EncodeConstants.SIZE_OF_BYTE_IN_BYTES;
+    private static final int NXM_FIELD_CODE = 5;
+    public static final MatchEntrySerializerKey<ExperimenterClass, NxmNxNsi> SERIALIZER_KEY =
+            createSerializerKey(
+                    EncodeConstants.OF13_VERSION_ID,
+                    NiciraConstants.NX_NSH_VENDOR_ID,
+                    NxmNxNsi.class);
+    public static final MatchEntryDeserializerKey DESERIALIZER_KEY =
+            createDeserializerKey(
+                    EncodeConstants.OF13_VERSION_ID,
+                    NiciraConstants.NX_NSH_VENDOR_ID,
+                    NXM_FIELD_CODE);
 
     @Override
-    public void serialize(MatchEntry input, ByteBuf outBuffer) {
-        serializeHeader(input, outBuffer);
-        NsiCaseValue nsiCaseValue = ((NsiCaseValue) input.getMatchEntryValue());
-        outBuffer.writeByte(nsiCaseValue.getNsiValues().getNsi());
+    protected void serializeValue(NxExpMatchEntryValue value, boolean hasMask, ByteBuf outBuffer) {
+        NsiCaseValue nsiCaseValue = (NsiCaseValue) value;
+        NsiValues nsiValues = nsiCaseValue.getNsiValues();
+        outBuffer.writeByte(nsiValues.getNsi());
+        if (hasMask) {
+            outBuffer.writeByte(nsiValues.getMask());
+        }
     }
 
     @Override
-    public MatchEntry deserialize(ByteBuf message) {
-        MatchEntryBuilder matchEntriesBuilder = deserializeHeaderToBuilder(message);
-        NsiCaseValueBuilder nsiCaseValueBuilder = new NsiCaseValueBuilder();
-        nsiCaseValueBuilder.setNsiValues(new NsiValuesBuilder().setNsi(message.readUnsignedByte()).build());
-        matchEntriesBuilder.setMatchEntryValue(nsiCaseValueBuilder.build());
-        matchEntriesBuilder.setHasMask(false);
-        return matchEntriesBuilder.build();
+    protected NxExpMatchEntryValue deserializeValue(ByteBuf message, boolean hasMask) {
+        Short value = message.readUnsignedByte();
+        Short mask = hasMask ? message.readUnsignedByte() : null;
+        NsiValues nsiValues = new NsiValuesBuilder().setNsi(value).setMask(mask).build();
+        return new NsiCaseValueBuilder().setNsiValues(nsiValues).build();
     }
 
     @Override
@@ -55,8 +61,8 @@ public class NsiCodec extends AbstractMatchCodec {
     }
 
     @Override
-    public int getOxmClassCode() {
-        return OxmMatchConstants.NXM_1_CLASS;
+    protected long getExperimenterId() {
+        return NiciraConstants.NX_NSH_VENDOR_ID;
     }
 
     @Override
@@ -68,9 +74,4 @@ public class NsiCodec extends AbstractMatchCodec {
     public Class<? extends MatchField> getNxmField() {
         return NxmNxNsi.class;
     }
-
-    @Override
-    public Class<? extends OxmClassBase> getOxmClass() {
-        return Nxm1Class.class;
-    }
 }
index d3c30ee01861f7e1001f474a40a2fa173e42f812..616a03ca747a83f205b3020dcc88dfc71a47cef6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Red Hat, Inc. and others.  All rights reserved.
+ * Copyright (c) 2018 SUSE LINUX GmbH.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -9,54 +9,60 @@
 package org.opendaylight.openflowjava.nx.codec.match;
 
 import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.nx.api.NiciraConstants;
 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey;
 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
-import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
-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.nx.match.rev140421.NxmNxNsp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsp.grouping.NspValues;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsp.grouping.NspValuesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.NspCaseValue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.NspCaseValueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NspCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NspCaseValueBuilder;
 
-public class NspCodec extends AbstractMatchCodec {
+public class NspCodec extends AbstractExperimenterMatchCodec {
 
-    private static final int VALUE_LENGTH = 4;
-    private static final int NXM_FIELD_CODE = 113;
-    public static final MatchEntrySerializerKey<Nxm1Class, NxmNxNsp> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
-            EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNsp.class);
-    public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
-            EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE);
+    private static final int VALUE_LENGTH = EncodeConstants.SIZE_OF_INT_IN_BYTES;
+    private static final int NXM_FIELD_CODE = 4;
+    public static final MatchEntrySerializerKey<ExperimenterClass, NxmNxNsp> SERIALIZER_KEY =
+            createSerializerKey(
+                    EncodeConstants.OF13_VERSION_ID,
+                    NiciraConstants.NX_NSH_VENDOR_ID,
+                    NxmNxNsp.class);
+    public static final MatchEntryDeserializerKey DESERIALIZER_KEY =
+            createDeserializerKey(
+                EncodeConstants.OF13_VERSION_ID,
+                NiciraConstants.NX_NSH_VENDOR_ID,
+                NXM_FIELD_CODE);
 
     @Override
-    public void serialize(MatchEntry input, ByteBuf outBuffer) {
-        serializeHeader(input, outBuffer);
-        NspCaseValue nspCaseValue = ((NspCaseValue) input.getMatchEntryValue());
-        outBuffer.writeInt(nspCaseValue.getNspValues().getNsp().intValue());
+    protected void serializeValue(NxExpMatchEntryValue value, boolean hasMask, ByteBuf outBuffer) {
+        NspCaseValue nspCaseValue = (NspCaseValue) value;
+        NspValues nspValues = nspCaseValue.getNspValues();
+        outBuffer.writeInt(nspValues.getNsp().intValue());
+        if (hasMask) {
+            outBuffer.writeInt(nspValues.getMask().intValue());
+        }
     }
 
     @Override
-    public MatchEntry deserialize(ByteBuf message) {
-        MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message);
-        NspCaseValueBuilder nspCaseValueBuilder = new NspCaseValueBuilder();
-        nspCaseValueBuilder.setNspValues(new NspValuesBuilder().setNsp(message.readUnsignedInt()).build());
-        matchEntryBuilder.setMatchEntryValue(nspCaseValueBuilder.build());
-        matchEntryBuilder.setHasMask(false);
-        return matchEntryBuilder.build();
+    protected NxExpMatchEntryValue deserializeValue(ByteBuf message, boolean hasMask) {
+        Long nspValue = message.readUnsignedInt();
+        Long maskValue = hasMask ? message.readUnsignedInt() : null;
+        NspValues nspValues = new NspValuesBuilder().setNsp(nspValue).setMask(maskValue).build();
+        return new NspCaseValueBuilder().setNspValues(nspValues).build();
     }
 
     @Override
-    public int getNxmFieldCode() {
-        return NXM_FIELD_CODE;
+    protected long getExperimenterId() {
+        return NiciraConstants.NX_NSH_VENDOR_ID;
     }
 
     @Override
-    public int getOxmClassCode() {
-        return OxmMatchConstants.NXM_1_CLASS;
+    public int getNxmFieldCode() {
+        return NXM_FIELD_CODE;
     }
 
     @Override
@@ -68,9 +74,4 @@ public class NspCodec extends AbstractMatchCodec {
     public Class<? extends MatchField> getNxmField() {
         return NxmNxNsp.class;
     }
-
-    @Override
-    public Class<? extends OxmClassBase> getOxmClass() {
-        return Nxm1Class.class;
-    }
 }
index 1e021a3bb2e150ca22e43f4ac3554f395c4a70df..bda31714d65818b9a6bc86cd7ae70816f8b5563f 100644 (file)
@@ -298,6 +298,9 @@ module nicira-match {
             leaf nsp {
                 type uint32;
             }
+            leaf mask {
+                type uint32;
+            }
         }
     }
 
@@ -306,6 +309,9 @@ module nicira-match {
             leaf nsi {
                 type uint8;
             }
+            leaf mask {
+                type uint8;
+            }
         }
     }
 
@@ -313,6 +319,9 @@ module nicira-match {
         leaf nshc {
             type uint32;
         }
+        leaf mask {
+            type uint32;
+        }
     }
 
     grouping ofj-nxm-nx-match-nshc-1-grouping {
@@ -593,36 +602,12 @@ module nicira-match {
         case encap-eth-dst-case-value {
             uses ofj-nxm-nx-match-encap-eth-dst-grouping;
         }
-        case nsh-mdtype-case-value {
-            uses ofj-nxm-nx-match-nsh-mdtype-grouping;
-        }
-        case nsh-np-case-value {
-            uses ofj-nxm-nx-match-nsh-np-grouping;
-        }
         case tun-gpe-np-case-value {
             uses ofj-nxm-nx-match-tun-gpe-np-grouping;
         }
         case eth-type-case-value {
             uses ofj-nxm-of-match-eth-type-grouping;
         }
-        case nsp-case-value {
-            uses ofj-nxm-nx-match-nsp-grouping;
-        }
-        case nsi-case-value {
-            uses ofj-nxm-nx-match-nsi-grouping;
-        }
-        case nshc-1-case-value {
-            uses ofj-nxm-nx-match-nshc-1-grouping;
-        }
-        case nshc-2-case-value {
-            uses ofj-nxm-nx-match-nshc-2-grouping;
-        }
-        case nshc-3-case-value {
-            uses ofj-nxm-nx-match-nshc-3-grouping;
-        }
-        case nshc-4-case-value {
-            uses ofj-nxm-nx-match-nshc-4-grouping;
-        }
         case tcp-src-case-value {
             uses ofj-nxm-of-match-tcp-src-grouping;
         }
@@ -670,6 +655,21 @@ module nicira-match {
             case nsh-flags-case-value {
                 uses ofj-nxm-nx-match-nsh-flags-grouping;
             }
+            case nsh-mdtype-case-value {
+                uses ofj-nxm-nx-match-nsh-mdtype-grouping;
+            }
+            case nsh-np-case-value {
+                uses ofj-nxm-nx-match-nsh-np-grouping;
+            }
+            case nsp-case-value {
+                uses ofj-nxm-nx-match-nsp-grouping;
+            }
+            case nsi-case-value {
+                uses ofj-nxm-nx-match-nsi-grouping;
+            }
+            case nshc-case-value {
+                uses ofj-nxm-nx-match-nshc-grouping;
+            }
             case nsh-ttl-case-value {
                 uses ofj-nxm-nx-match-nsh-ttl-grouping;
             }
index ea55f53cea0f8de5b893dcfddf6ccd0567d00ffb..a04124cc9614877812e095618311ea7bf4c4d0bb 100644 (file)
@@ -44,6 +44,8 @@ import org.opendaylight.openflowjava.nx.codec.match.EthDstCodec;
 import org.opendaylight.openflowjava.nx.codec.match.EthSrcCodec;
 import org.opendaylight.openflowjava.nx.codec.match.EthTypeCodec;
 import org.opendaylight.openflowjava.nx.codec.match.NshFlagsCodec;
+import org.opendaylight.openflowjava.nx.codec.match.NshMdtypeCodec;
+import org.opendaylight.openflowjava.nx.codec.match.NshNpCodec;
 import org.opendaylight.openflowjava.nx.codec.match.NshTtlCodec;
 import org.opendaylight.openflowjava.nx.codec.match.Nshc1Codec;
 import org.opendaylight.openflowjava.nx.codec.match.Nshc2Codec;
@@ -95,6 +97,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev14
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxCtTpSrc;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxCtZone;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNshFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNshMdtype;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNshNp;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNshTtl;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNshc1;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNshc2;
@@ -311,42 +315,6 @@ public class NiciraExtensionsRegistratorTest {
         Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers
                 .eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, 3)),
                 Matchers.any(EthTypeCodec.class));
-        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers
-                .eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNsp.class)),
-                Matchers.any(NspCodec.class));
-        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers
-                .eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 113)),
-                Matchers.any(NspCodec.class));
-        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers
-                .eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNshc1.class)),
-                Matchers.any(Nshc1Codec.class));
-        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers
-                .eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 115)),
-                Matchers.any(Nshc1Codec.class));
-        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers
-                .eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNshc2.class)),
-                Matchers.any(Nshc2Codec.class));
-        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers
-                .eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 116)),
-                Matchers.any(Nshc2Codec.class));
-        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers
-                .eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNshc3.class)),
-                Matchers.any(Nshc3Codec.class));
-        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers
-                .eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 117)),
-                Matchers.any(Nshc3Codec.class));
-        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers
-                .eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNshc4.class)),
-                Matchers.any(Nshc4Codec.class));
-        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers
-                .eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 118)),
-                Matchers.any(Nshc4Codec.class));
-        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers
-                .eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNsi.class)),
-                Matchers.any(NsiCodec.class));
-        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers
-                .eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 114)),
-                Matchers.any(NsiCodec.class));
         Mockito.verify(registrator).registerMatchEntrySerializer(Matchers.eq(
                 new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxTunIpv4Dst.class)),
                 Matchers.any(TunIpv4DstCodec.class));
@@ -443,6 +411,134 @@ public class NiciraExtensionsRegistratorTest {
         Mockito.verify(registrator).registerMatchEntryDeserializer(
                 Matchers.eq(nshFlagsDeserializerKey),
                 Matchers.any(NshFlagsCodec.class));
+        MatchEntrySerializerKey<ExperimenterClass, NxmNxNshMdtype> mdtypeSerializerKey = new MatchEntrySerializerKey<>(
+                EncodeConstants.OF13_VERSION_ID,
+                ExperimenterClass.class,
+                NxmNxNshMdtype.class);
+        mdtypeSerializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
+        Mockito.verify(registrator).registerMatchEntrySerializer(
+                Matchers.eq(mdtypeSerializerKey),
+                Matchers.any(NshMdtypeCodec.class));
+        MatchEntryDeserializerKey mdtypeDeserializerKey = new MatchEntryDeserializerKey(
+                EncodeConstants.OF13_VERSION_ID,
+                OxmMatchConstants.EXPERIMENTER_CLASS,
+                2);
+        mdtypeDeserializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
+        Mockito.verify(registrator).registerMatchEntryDeserializer(
+                Matchers.eq(mdtypeDeserializerKey),
+                Matchers.any(NshMdtypeCodec.class));
+        MatchEntrySerializerKey<ExperimenterClass, NxmNxNshNp> nshNpSerializerKey = new MatchEntrySerializerKey<>(
+                EncodeConstants.OF13_VERSION_ID,
+                ExperimenterClass.class,
+                NxmNxNshNp.class);
+        nshNpSerializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
+        Mockito.verify(registrator).registerMatchEntrySerializer(
+                Matchers.eq(nshNpSerializerKey),
+                Matchers.any(NshNpCodec.class));
+        MatchEntryDeserializerKey nshNpDeserializerKey = new MatchEntryDeserializerKey(
+                EncodeConstants.OF13_VERSION_ID,
+                OxmMatchConstants.EXPERIMENTER_CLASS,
+                3);
+        nshNpDeserializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
+        Mockito.verify(registrator).registerMatchEntryDeserializer(
+                Matchers.eq(nshNpDeserializerKey),
+                Matchers.any(NshNpCodec.class));
+        MatchEntrySerializerKey<ExperimenterClass, NxmNxNsp> nspSerializerKey = new MatchEntrySerializerKey<>(
+                EncodeConstants.OF13_VERSION_ID,
+                ExperimenterClass.class,
+                NxmNxNsp.class);
+        nspSerializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
+        Mockito.verify(registrator).registerMatchEntrySerializer(
+                Matchers.eq(nspSerializerKey),
+                Matchers.any(NspCodec.class));
+        MatchEntryDeserializerKey nspDeserializerKey = new MatchEntryDeserializerKey(
+                EncodeConstants.OF13_VERSION_ID,
+                OxmMatchConstants.EXPERIMENTER_CLASS,
+                4);
+        nspDeserializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
+        Mockito.verify(registrator).registerMatchEntryDeserializer(
+                Matchers.eq(nspDeserializerKey),
+                Matchers.any(NspCodec.class));
+        MatchEntrySerializerKey<ExperimenterClass, NxmNxNsi> nsiSerializerKey = new MatchEntrySerializerKey<>(
+                EncodeConstants.OF13_VERSION_ID,
+                ExperimenterClass.class,
+                NxmNxNsi.class);
+        nsiSerializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
+        Mockito.verify(registrator).registerMatchEntrySerializer(
+                Matchers.eq(nsiSerializerKey),
+                Matchers.any(NsiCodec.class));
+        MatchEntryDeserializerKey nsiDeserializerKey = new MatchEntryDeserializerKey(
+                EncodeConstants.OF13_VERSION_ID,
+                OxmMatchConstants.EXPERIMENTER_CLASS,
+                5);
+        nsiDeserializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
+        Mockito.verify(registrator).registerMatchEntryDeserializer(
+                Matchers.eq(nsiDeserializerKey),
+                Matchers.any(NsiCodec.class));
+        MatchEntrySerializerKey<ExperimenterClass, NxmNxNshc1> nshc1SerializerKey = new MatchEntrySerializerKey<>(
+                EncodeConstants.OF13_VERSION_ID,
+                ExperimenterClass.class,
+                NxmNxNshc1.class);
+        nshc1SerializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
+        Mockito.verify(registrator).registerMatchEntrySerializer(
+                Matchers.eq(nshc1SerializerKey),
+                Matchers.any(Nshc1Codec.class));
+        MatchEntryDeserializerKey nshc1DeserializerKey = new MatchEntryDeserializerKey(
+                EncodeConstants.OF13_VERSION_ID,
+                OxmMatchConstants.EXPERIMENTER_CLASS,
+                6);
+        nshc1DeserializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
+        Mockito.verify(registrator).registerMatchEntryDeserializer(
+                Matchers.eq(nshc1DeserializerKey),
+                Matchers.any(Nshc1Codec.class));
+        MatchEntrySerializerKey<ExperimenterClass, NxmNxNshc2> nshc2SerializerKey = new MatchEntrySerializerKey<>(
+                EncodeConstants.OF13_VERSION_ID,
+                ExperimenterClass.class,
+                NxmNxNshc2.class);
+        nshc2SerializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
+        Mockito.verify(registrator).registerMatchEntrySerializer(
+                Matchers.eq(nshc2SerializerKey),
+                Matchers.any(Nshc2Codec.class));
+        MatchEntryDeserializerKey nshc2DeserializerKey = new MatchEntryDeserializerKey(
+                EncodeConstants.OF13_VERSION_ID,
+                OxmMatchConstants.EXPERIMENTER_CLASS,
+                7);
+        nshc2DeserializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
+        Mockito.verify(registrator).registerMatchEntryDeserializer(
+                Matchers.eq(nshc2DeserializerKey),
+                Matchers.any(Nshc2Codec.class));
+        MatchEntrySerializerKey<ExperimenterClass, NxmNxNshc3> nshc3SerializerKey = new MatchEntrySerializerKey<>(
+                EncodeConstants.OF13_VERSION_ID,
+                ExperimenterClass.class,
+                NxmNxNshc3.class);
+        nshc3SerializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
+        Mockito.verify(registrator).registerMatchEntrySerializer(
+                Matchers.eq(nshc3SerializerKey),
+                Matchers.any(Nshc3Codec.class));
+        MatchEntryDeserializerKey nshc3DeserializerKey = new MatchEntryDeserializerKey(
+                EncodeConstants.OF13_VERSION_ID,
+                OxmMatchConstants.EXPERIMENTER_CLASS,
+                8);
+        nshc3DeserializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
+        Mockito.verify(registrator).registerMatchEntryDeserializer(
+                Matchers.eq(nshc3DeserializerKey),
+                Matchers.any(Nshc3Codec.class));
+        MatchEntrySerializerKey<ExperimenterClass, NxmNxNshc4> nshc4SerializerKey = new MatchEntrySerializerKey<>(
+                EncodeConstants.OF13_VERSION_ID,
+                ExperimenterClass.class,
+                NxmNxNshc4.class);
+        nshc4SerializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
+        Mockito.verify(registrator).registerMatchEntrySerializer(
+                Matchers.eq(nshc4SerializerKey),
+                Matchers.any(Nshc4Codec.class));
+        MatchEntryDeserializerKey nshc4DeserializerKey = new MatchEntryDeserializerKey(
+                EncodeConstants.OF13_VERSION_ID,
+                OxmMatchConstants.EXPERIMENTER_CLASS,
+                9);
+        nshc4DeserializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
+        Mockito.verify(registrator).registerMatchEntryDeserializer(
+                Matchers.eq(nshc4DeserializerKey),
+                Matchers.any(Nshc4Codec.class));
         MatchEntrySerializerKey<ExperimenterClass, NxmNxNshTtl> nshTtlSerializerKey = new MatchEntrySerializerKey<>(
                 EncodeConstants.OF13_VERSION_ID,
                 ExperimenterClass.class,
@@ -585,30 +681,6 @@ public class NiciraExtensionsRegistratorTest {
                 new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfEthType.class));
         Mockito.verify(registrator).unregisterMatchEntryDeserializer(
                 new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, 3));
-        Mockito.verify(registrator).unregisterMatchEntrySerializer(
-                new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNsp.class));
-        Mockito.verify(registrator).unregisterMatchEntryDeserializer(
-                new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 113));
-        Mockito.verify(registrator).unregisterMatchEntrySerializer(
-                new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNsi.class));
-        Mockito.verify(registrator).unregisterMatchEntryDeserializer(
-                new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 114));
-        Mockito.verify(registrator).unregisterMatchEntrySerializer(
-                new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNshc1.class));
-        Mockito.verify(registrator).unregisterMatchEntryDeserializer(
-                new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 115));
-        Mockito.verify(registrator).unregisterMatchEntrySerializer(
-                new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNshc2.class));
-        Mockito.verify(registrator).unregisterMatchEntryDeserializer(
-                new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 116));
-        Mockito.verify(registrator).unregisterMatchEntrySerializer(
-                new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNshc3.class));
-        Mockito.verify(registrator).unregisterMatchEntryDeserializer(
-                new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 117));
-        Mockito.verify(registrator).unregisterMatchEntrySerializer(
-                new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNshc4.class));
-        Mockito.verify(registrator).unregisterMatchEntryDeserializer(
-                new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 118));
         Mockito.verify(registrator).unregisterMatchEntrySerializer(
                 new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxTunIpv4Dst.class));
         Mockito.verify(registrator).unregisterMatchEntryDeserializer(
@@ -671,6 +743,102 @@ public class NiciraExtensionsRegistratorTest {
                 1);
         nshFlagsDeserializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
         Mockito.verify(registrator).unregisterMatchEntryDeserializer(nshFlagsDeserializerKey);
+        MatchEntrySerializerKey<ExperimenterClass, NxmNxNshMdtype> mdtypeSerializerKey = new MatchEntrySerializerKey<>(
+                EncodeConstants.OF13_VERSION_ID,
+                ExperimenterClass.class,
+                NxmNxNshMdtype.class);
+        mdtypeSerializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(mdtypeSerializerKey);
+        MatchEntryDeserializerKey mdtypeDeserializerKey = new MatchEntryDeserializerKey(
+                EncodeConstants.OF13_VERSION_ID,
+                OxmMatchConstants.EXPERIMENTER_CLASS,
+                2);
+        mdtypeDeserializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(mdtypeDeserializerKey);
+        MatchEntrySerializerKey<ExperimenterClass, NxmNxNshNp> nshNpSerializerKey = new MatchEntrySerializerKey<>(
+                EncodeConstants.OF13_VERSION_ID,
+                ExperimenterClass.class,
+                NxmNxNshNp.class);
+        nshNpSerializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(nshNpSerializerKey);
+        MatchEntryDeserializerKey nshNpDeserializerKey = new MatchEntryDeserializerKey(
+                EncodeConstants.OF13_VERSION_ID,
+                OxmMatchConstants.EXPERIMENTER_CLASS,
+                3);
+        nshNpDeserializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(nshNpDeserializerKey);
+        MatchEntrySerializerKey<ExperimenterClass, NxmNxNsp> nspSerializerKey = new MatchEntrySerializerKey<>(
+                EncodeConstants.OF13_VERSION_ID,
+                ExperimenterClass.class,
+                NxmNxNsp.class);
+        nspSerializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(nspSerializerKey);
+        MatchEntryDeserializerKey nspDeserializerKey = new MatchEntryDeserializerKey(
+                EncodeConstants.OF13_VERSION_ID,
+                OxmMatchConstants.EXPERIMENTER_CLASS,
+                4);
+        nspDeserializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(nspDeserializerKey);
+        MatchEntrySerializerKey<ExperimenterClass, NxmNxNsi> nsiSerializerKey = new MatchEntrySerializerKey<>(
+                EncodeConstants.OF13_VERSION_ID,
+                ExperimenterClass.class,
+                NxmNxNsi.class);
+        nsiSerializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(nsiSerializerKey);
+        MatchEntryDeserializerKey nsiDeserializerKey = new MatchEntryDeserializerKey(
+                EncodeConstants.OF13_VERSION_ID,
+                OxmMatchConstants.EXPERIMENTER_CLASS,
+                5);
+        nsiDeserializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(nsiDeserializerKey);
+        MatchEntrySerializerKey<ExperimenterClass, NxmNxNshc1> nshc1SerializerKey = new MatchEntrySerializerKey<>(
+                EncodeConstants.OF13_VERSION_ID,
+                ExperimenterClass.class,
+                NxmNxNshc1.class);
+        nshc1SerializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(nshc1SerializerKey);
+        MatchEntryDeserializerKey nshc1DeserializerKey = new MatchEntryDeserializerKey(
+                EncodeConstants.OF13_VERSION_ID,
+                OxmMatchConstants.EXPERIMENTER_CLASS,
+                6);
+        nshc1DeserializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(nshc1DeserializerKey);
+        MatchEntrySerializerKey<ExperimenterClass, NxmNxNshc2> nshc2SerializerKey = new MatchEntrySerializerKey<>(
+                EncodeConstants.OF13_VERSION_ID,
+                ExperimenterClass.class,
+                NxmNxNshc2.class);
+        nshc2SerializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(nshc2SerializerKey);
+        MatchEntryDeserializerKey nshc2DeserializerKey = new MatchEntryDeserializerKey(
+                EncodeConstants.OF13_VERSION_ID,
+                OxmMatchConstants.EXPERIMENTER_CLASS,
+                7);
+        nshc2DeserializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(nshc2DeserializerKey);
+        MatchEntrySerializerKey<ExperimenterClass, NxmNxNshc3> nshc3SerializerKey = new MatchEntrySerializerKey<>(
+                EncodeConstants.OF13_VERSION_ID,
+                ExperimenterClass.class,
+                NxmNxNshc3.class);
+        nshc3SerializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(nshc3SerializerKey);
+        MatchEntryDeserializerKey nshc3DeserializerKey = new MatchEntryDeserializerKey(
+                EncodeConstants.OF13_VERSION_ID,
+                OxmMatchConstants.EXPERIMENTER_CLASS,
+                8);
+        nshc3DeserializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(nshc3DeserializerKey);
+        MatchEntrySerializerKey<ExperimenterClass, NxmNxNshc4> nshc4SerializerKey = new MatchEntrySerializerKey<>(
+                EncodeConstants.OF13_VERSION_ID,
+                ExperimenterClass.class,
+                NxmNxNshc4.class);
+        nshc4SerializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(nshc1SerializerKey);
+        MatchEntryDeserializerKey nshc4DeserializerKey = new MatchEntryDeserializerKey(
+                EncodeConstants.OF13_VERSION_ID,
+                OxmMatchConstants.EXPERIMENTER_CLASS,
+                9);
+        nshc4DeserializerKey.setExperimenterId(NiciraConstants.NX_NSH_VENDOR_ID);
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(nshc4DeserializerKey);
         MatchEntrySerializerKey<ExperimenterClass, NxmNxNshTtl> nshTtlSerializerKey = new MatchEntrySerializerKey<>(
                 EncodeConstants.OF13_VERSION_ID,
                 ExperimenterClass.class,
diff --git a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/AbstractNshcCodecTest.java b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/AbstractNshcCodecTest.java
new file mode 100644 (file)
index 0000000..d38e06b
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2018 SUSE LINUX GmbH.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.nx.codec.match;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufAllocator;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshcCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshcCaseValueBuilder;
+
+public class AbstractNshcCodecTest {
+
+    private class TestCodec extends AbstractNshcCodec {
+
+        @Override
+        public int getNxmFieldCode() {
+            return 0;
+        }
+
+        @Override
+        public Class<? extends MatchField> getNxmField() {
+            return null;
+        }
+    }
+
+    private AbstractNshcCodec testCodec;
+    private ByteBuf buffer;
+
+    private static final Long NSHC_VALUE = 10L;
+    private static final Long NSHC_MASK = 0xFL;
+
+    @Before
+    public void setUp() {
+        testCodec = new TestCodec();
+        buffer = ByteBufAllocator.DEFAULT.buffer();
+    }
+
+    @Test
+    public void serializeTestNoMask() {
+        NxExpMatchEntryValue matchEntryValue = createMatchEntryValue(NSHC_VALUE, null);
+
+        testCodec.serializeValue(matchEntryValue, false, buffer);
+
+        assertEquals(NSHC_VALUE.longValue(), buffer.readUnsignedInt());
+        assertFalse(buffer.isReadable());
+    }
+
+    @Test
+    public void serializeTestMask() {
+        NxExpMatchEntryValue matchEntryValue = createMatchEntryValue(NSHC_VALUE, NSHC_MASK);
+
+        testCodec.serializeValue(matchEntryValue, true, buffer);
+
+        assertEquals(NSHC_VALUE.longValue(), buffer.readUnsignedInt());
+        assertEquals(NSHC_MASK.longValue(), buffer.readUnsignedInt());
+        assertFalse(buffer.isReadable());
+    }
+
+    @Test
+    public void deserializeTestNoMask() {
+        writeBuffer(buffer, NSHC_VALUE, null);
+
+        NxExpMatchEntryValue value = testCodec.deserializeValue(buffer, false);
+
+        assertEquals(NSHC_VALUE, ((NshcCaseValue) value).getNshc());
+        assertFalse(buffer.isReadable());
+    }
+
+    @Test
+    public void deserializeTestMask() {
+        writeBuffer(buffer, NSHC_VALUE, NSHC_MASK);
+
+        NxExpMatchEntryValue value = testCodec.deserializeValue(buffer, true);
+
+        assertEquals(NSHC_VALUE, ((NshcCaseValue) value).getNshc());
+        assertEquals(NSHC_MASK, ((NshcCaseValue) value).getMask());
+        assertFalse(buffer.isReadable());
+    }
+
+
+    private NxExpMatchEntryValue createMatchEntryValue(Long value, Long mask) {
+        return new NshcCaseValueBuilder().setNshc(value).setMask(mask).build();
+    }
+
+    private void writeBuffer(ByteBuf message, Long value, Long mask) {
+        message.writeInt(value.intValue());
+        if (mask != null) {
+            message.writeInt(mask.intValue());
+        }
+    }
+}
\ No newline at end of file
diff --git a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NshMdtypeCodecTest.java b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NshMdtypeCodecTest.java
new file mode 100644 (file)
index 0000000..7f16045
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2018 SUSE LINUX GmbH.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.nx.codec.match;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufAllocator;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsh.mdtype.grouping.NshMdtypeValues;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsh.mdtype.grouping.NshMdtypeValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshMdtypeCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshMdtypeCaseValueBuilder;
+
+public class NshMdtypeCodecTest {
+
+    private NshMdtypeCodec nshMdtypeCodec;
+    private ByteBuf buffer;
+
+    private static final Short MDTYPE_VALUE = (short) 1;
+
+    @Before
+    public void setUp() {
+        nshMdtypeCodec = new NshMdtypeCodec();
+        buffer = ByteBufAllocator.DEFAULT.buffer();
+    }
+
+    @Test
+    public void serializeValueTest() {
+        NxExpMatchEntryValue matchEntryValue = createMatchEntryValue(MDTYPE_VALUE);
+
+        nshMdtypeCodec.serializeValue(matchEntryValue, false, buffer);
+
+        assertEquals(MDTYPE_VALUE.shortValue(), buffer.readUnsignedByte());
+        assertFalse(buffer.isReadable());
+    }
+
+    @Test
+    public void deserializeValueTest() {
+        writeBuffer(buffer, MDTYPE_VALUE);
+
+        NxExpMatchEntryValue value = nshMdtypeCodec.deserializeValue(buffer, false);
+
+        assertEquals(MDTYPE_VALUE, ((NshMdtypeCaseValue) value).getNshMdtypeValues().getValue());
+        assertFalse(buffer.isReadable());
+    }
+
+    private NxExpMatchEntryValue createMatchEntryValue(Short value) {
+        NshMdtypeValues nshMdtypeValues = new NshMdtypeValuesBuilder().setValue(value).build();
+        return new NshMdtypeCaseValueBuilder().setNshMdtypeValues(nshMdtypeValues).build();
+    }
+
+    private void writeBuffer(ByteBuf message, Short value) {
+        message.writeByte(value.intValue());
+    }
+}
\ No newline at end of file
diff --git a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NshNpCodecTest.java b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NshNpCodecTest.java
new file mode 100644 (file)
index 0000000..b521771
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2018 SUSE LINUX GmbH.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.nx.codec.match;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufAllocator;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsh.np.grouping.NshNpValues;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsh.np.grouping.NshNpValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshNpCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshNpCaseValueBuilder;
+
+public class NshNpCodecTest {
+
+    private NshNpCodec nshNpCodec;
+    private ByteBuf buffer;
+
+    private static final Short NP_VALUE = (short) 3;
+
+    @Before
+    public void setUp() {
+        nshNpCodec = new NshNpCodec();
+        buffer = ByteBufAllocator.DEFAULT.buffer();
+    }
+
+    @Test
+    public void serializeValueTest() {
+        NxExpMatchEntryValue matchEntryValue = createMatchEntryValue(NP_VALUE);
+
+        nshNpCodec.serializeValue(matchEntryValue, false, buffer);
+
+        assertEquals(NP_VALUE.shortValue(), buffer.readUnsignedByte());
+        assertFalse(buffer.isReadable());
+    }
+
+    @Test
+    public void deserializeValueTest() {
+        writeBuffer(buffer, NP_VALUE);
+
+        NxExpMatchEntryValue value = nshNpCodec.deserializeValue(buffer, false);
+
+        assertEquals(NP_VALUE, ((NshNpCaseValue) value).getNshNpValues().getValue());
+        assertFalse(buffer.isReadable());
+    }
+
+    private NxExpMatchEntryValue createMatchEntryValue(Short value) {
+        NshNpValues nshNpValues = new NshNpValuesBuilder().setValue(value).build();
+        return new NshNpCaseValueBuilder().setNshNpValues(nshNpValues).build();
+    }
+
+    private void writeBuffer(ByteBuf message, Short value) {
+        message.writeByte(value.intValue());
+    }
+}
\ No newline at end of file
diff --git a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/Nshc1CodecTest.java b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/Nshc1CodecTest.java
deleted file mode 100644 (file)
index b0f2051..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.openflowjava.nx.codec.match;
-
-import 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.protocol.api.util.OxmMatchConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
-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.nx.match.rev140421.NxmNxNshc1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nshc._1.grouping.Nshc1ValuesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc1CaseValue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc1CaseValueBuilder;
-
-public class Nshc1CodecTest {
-
-    Nshc1Codec nshc1Codec;
-    ByteBuf buffer;
-    MatchEntry input;
-
-    private static final int VALUE_LENGTH = 4;
-    private static final int NXM_FIELD_CODE = 115;
-
-    @Before
-    public void setUp() {
-        nshc1Codec = new Nshc1Codec();
-        buffer = ByteBufAllocator.DEFAULT.buffer();
-    }
-
-    @Test
-    public void serializeTest() {
-        input = createMatchEntry();
-        nshc1Codec.serialize(input, buffer);
-
-        assertEquals(OxmMatchConstants.NXM_1_CLASS, buffer.readUnsignedShort());
-        short fieldMask = buffer.readUnsignedByte();
-        assertEquals(NXM_FIELD_CODE, fieldMask >> 1);
-        assertEquals(0, fieldMask & 1);
-        assertEquals(VALUE_LENGTH, buffer.readUnsignedByte());
-        assertEquals(1, buffer.readUnsignedInt());
-    }
-
-    @Test
-    public void deserializeTest() {
-        createBuffer(buffer);
-
-        input = nshc1Codec.deserialize(buffer);
-
-        final Nshc1CaseValue result = (Nshc1CaseValue) input.getMatchEntryValue();
-
-        assertEquals(Nxm1Class.class, input.getOxmClass());
-        assertEquals(NxmNxNshc1.class, input.getOxmMatchField());
-        assertEquals(false, input.isHasMask());
-        assertEquals(2, result.getNshc1Values().getNshc().intValue());
-    }
-
-
-    private MatchEntry createMatchEntry() {
-        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-        final Nshc1CaseValueBuilder caseBuilder = new Nshc1CaseValueBuilder();
-        final Nshc1ValuesBuilder valuesBuilder = new Nshc1ValuesBuilder();
-
-        matchEntryBuilder.setOxmClass(Nxm1Class.class);
-        matchEntryBuilder.setOxmMatchField(NxmNxNshc1.class);
-        matchEntryBuilder.setHasMask(false);
-
-        valuesBuilder.setNshc((long)1);
-
-        caseBuilder.setNshc1Values(valuesBuilder.build());
-        matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
-        return matchEntryBuilder.build();
-    }
-
-    private void createBuffer(ByteBuf message) {
-        message.writeShort(OxmMatchConstants.NXM_1_CLASS);
-
-        int fieldMask = NXM_FIELD_CODE << 1;
-        message.writeByte(fieldMask);
-        message.writeByte(VALUE_LENGTH);
-        message.writeInt(2);
-    }
-}
diff --git a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/Nshc2CodecTest.java b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/Nshc2CodecTest.java
deleted file mode 100644 (file)
index f7c4bee..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.openflowjava.nx.codec.match;
-
-import 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.protocol.api.util.OxmMatchConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
-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.nx.match.rev140421.NxmNxNshc2;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nshc._2.grouping.Nshc2ValuesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc2CaseValue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc2CaseValueBuilder;
-
-public class Nshc2CodecTest {
-
-    Nshc2Codec nshc2Codec;
-    ByteBuf buffer;
-    MatchEntry input;
-
-    private static final int VALUE_LENGTH = 4;
-    private static final int NXM_FIELD_CODE = 116;
-
-
-    @Before
-    public void setUp() {
-        nshc2Codec = new Nshc2Codec();
-        buffer = ByteBufAllocator.DEFAULT.buffer();
-    }
-
-    @Test
-    public void serializeTest() {
-        input = createMatchEntry();
-        nshc2Codec.serialize(input, buffer);
-
-        assertEquals(OxmMatchConstants.NXM_1_CLASS, buffer.readUnsignedShort());
-        short fieldMask = buffer.readUnsignedByte();
-        assertEquals(NXM_FIELD_CODE, fieldMask >> 1);
-        assertEquals(0, fieldMask & 1);
-        assertEquals(VALUE_LENGTH, buffer.readUnsignedByte());
-        assertEquals(1, buffer.readUnsignedInt());
-    }
-
-    @Test
-    public void deserializeTest() {
-        createBuffer(buffer);
-
-        input = nshc2Codec.deserialize(buffer);
-
-        final Nshc2CaseValue result = (Nshc2CaseValue) input.getMatchEntryValue();
-
-        assertEquals(Nxm1Class.class, input.getOxmClass());
-        assertEquals(NxmNxNshc2.class, input.getOxmMatchField());
-        assertEquals(false, input.isHasMask());
-        assertEquals(2, result.getNshc2Values().getNshc().intValue());
-    }
-
-    private MatchEntry createMatchEntry() {
-        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-        final Nshc2CaseValueBuilder caseBuilder = new Nshc2CaseValueBuilder();
-        final Nshc2ValuesBuilder valuesBuilder = new Nshc2ValuesBuilder();
-
-        matchEntryBuilder.setOxmClass(Nxm1Class.class);
-        matchEntryBuilder.setOxmMatchField(NxmNxNshc2.class);
-        matchEntryBuilder.setHasMask(false);
-
-        valuesBuilder.setNshc((long)1);
-
-        caseBuilder.setNshc2Values(valuesBuilder.build());
-        matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
-        return matchEntryBuilder.build();
-    }
-
-    private void createBuffer(ByteBuf message) {
-        message.writeShort(OxmMatchConstants.NXM_1_CLASS);
-
-        int fieldMask = NXM_FIELD_CODE << 1;
-        message.writeByte(fieldMask);
-        message.writeByte(VALUE_LENGTH);
-        message.writeInt(2);
-    }
-}
diff --git a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/Nshc3CodecTest.java b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/Nshc3CodecTest.java
deleted file mode 100644 (file)
index de85ef9..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.openflowjava.nx.codec.match;
-
-import 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.protocol.api.util.OxmMatchConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
-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.nx.match.rev140421.NxmNxNshc3;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nshc._3.grouping.Nshc3ValuesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc3CaseValue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc3CaseValueBuilder;
-
-public class Nshc3CodecTest {
-
-    Nshc3Codec nshc3Codec;
-    ByteBuf buffer;
-    MatchEntry input;
-
-    private static final int VALUE_LENGTH = 4;
-    private static final int NXM_FIELD_CODE = 117;
-
-    @Before
-    public void setUp() {
-        nshc3Codec = new Nshc3Codec();
-        buffer = ByteBufAllocator.DEFAULT.buffer();
-    }
-
-    @Test
-    public void serializeTest() {
-        input = createMatchEntry();
-        nshc3Codec.serialize(input, buffer);
-
-        assertEquals(OxmMatchConstants.NXM_1_CLASS, buffer.readUnsignedShort());
-        short fieldMask = buffer.readUnsignedByte();
-        assertEquals(NXM_FIELD_CODE, fieldMask >> 1);
-        assertEquals(0, fieldMask & 1);
-        assertEquals(VALUE_LENGTH, buffer.readUnsignedByte());
-        assertEquals(1, buffer.readUnsignedInt());
-    }
-
-    @Test
-    public void deserializeTest() {
-        createBuffer(buffer);
-
-        input = nshc3Codec.deserialize(buffer);
-
-        final Nshc3CaseValue result = (Nshc3CaseValue) input.getMatchEntryValue();
-
-        assertEquals(Nxm1Class.class, input.getOxmClass());
-        assertEquals(NxmNxNshc3.class, input.getOxmMatchField());
-        assertEquals(false, input.isHasMask());
-        assertEquals(2, result.getNshc3Values().getNshc().intValue());
-    }
-
-
-    private MatchEntry createMatchEntry() {
-        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-        final Nshc3CaseValueBuilder caseBuilder = new Nshc3CaseValueBuilder();
-        final Nshc3ValuesBuilder valuesBuilder = new Nshc3ValuesBuilder();
-
-        matchEntryBuilder.setOxmClass(Nxm1Class.class);
-        matchEntryBuilder.setOxmMatchField(NxmNxNshc3.class);
-        matchEntryBuilder.setHasMask(false);
-
-        valuesBuilder.setNshc((long)1);
-
-        caseBuilder.setNshc3Values(valuesBuilder.build());
-        matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
-        return matchEntryBuilder.build();
-    }
-
-    private void createBuffer(ByteBuf message) {
-        message.writeShort(OxmMatchConstants.NXM_1_CLASS);
-
-        int fieldMask = NXM_FIELD_CODE << 1;
-        message.writeByte(fieldMask);
-        message.writeByte(VALUE_LENGTH);
-        message.writeInt(2);
-    }
-}
diff --git a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/Nshc4CodecTest.java b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/Nshc4CodecTest.java
deleted file mode 100644 (file)
index 86a0978..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.openflowjava.nx.codec.match;
-
-import 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.protocol.api.util.OxmMatchConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
-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.nx.match.rev140421.NxmNxNshc4;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nshc._4.grouping.Nshc4ValuesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc4CaseValue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc4CaseValueBuilder;
-
-public class Nshc4CodecTest {
-
-    Nshc4Codec nshc4Codec;
-    ByteBuf buffer;
-    MatchEntry input;
-
-    private static final int VALUE_LENGTH = 4;
-    private static final int NXM_FIELD_CODE = 118;
-
-    @Before
-    public void setUp() {
-        nshc4Codec = new Nshc4Codec();
-        buffer = ByteBufAllocator.DEFAULT.buffer();
-    }
-
-    @Test
-    public void serializeTest() {
-        input = createMatchEntry();
-        nshc4Codec.serialize(input, buffer);
-
-        assertEquals(OxmMatchConstants.NXM_1_CLASS, buffer.readUnsignedShort());
-        short fieldMask = buffer.readUnsignedByte();
-        assertEquals(NXM_FIELD_CODE, fieldMask >> 1);
-        assertEquals(0, fieldMask & 1);
-        assertEquals(VALUE_LENGTH, buffer.readUnsignedByte());
-        assertEquals(1, buffer.readUnsignedInt());
-    }
-
-    @Test
-    public void deserializeTest() {
-        createBuffer(buffer);
-
-        input = nshc4Codec.deserialize(buffer);
-
-        final Nshc4CaseValue result = (Nshc4CaseValue) input.getMatchEntryValue();
-
-        assertEquals(Nxm1Class.class, input.getOxmClass());
-        assertEquals(NxmNxNshc4.class, input.getOxmMatchField());
-        assertEquals(false, input.isHasMask());
-        assertEquals(2, result.getNshc4Values().getNshc().intValue());
-    }
-
-
-    private MatchEntry createMatchEntry() {
-        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-        final Nshc4CaseValueBuilder caseBuilder = new Nshc4CaseValueBuilder();
-        final Nshc4ValuesBuilder valuesBuilder = new Nshc4ValuesBuilder();
-
-        matchEntryBuilder.setOxmClass(Nxm1Class.class);
-        matchEntryBuilder.setOxmMatchField(NxmNxNshc4.class);
-        matchEntryBuilder.setHasMask(false);
-
-        valuesBuilder.setNshc((long)1);
-
-        caseBuilder.setNshc4Values(valuesBuilder.build());
-        matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
-        return matchEntryBuilder.build();
-    }
-
-    private void createBuffer(ByteBuf message) {
-        message.writeShort(OxmMatchConstants.NXM_1_CLASS);
-
-        int fieldMask = NXM_FIELD_CODE << 1;
-        message.writeByte(fieldMask);
-        message.writeByte(VALUE_LENGTH);
-        message.writeInt(2);
-    }
-}
index c935b99bf0175e6ee1c7f5648eb794e6232c6833..0fc6a2c8baf1987e95592585c35022e834f2acd5 100644 (file)
@@ -9,28 +9,25 @@
 package org.opendaylight.openflowjava.nx.codec.match;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.ByteBufAllocator;
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
-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.nx.match.rev140421.NxmNxNsi;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsi.grouping.NsiValues;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsi.grouping.NsiValuesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.NsiCaseValue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.NsiCaseValueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NsiCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NsiCaseValueBuilder;
 
 public class NsiCodecTest {
 
     NsiCodec nsiCodec;
     ByteBuf buffer;
-    MatchEntry input;
 
-    private static final int VALUE_LENGTH = 1;
-    private static final int NXM_FIELD_CODE = 114;
+    private static final Short NSI_VALUE = (short) 255;
+    private static final Short NSI_MASK = 0xF0;
 
     @Before
     public void setUp() {
@@ -39,55 +36,56 @@ public class NsiCodecTest {
     }
 
     @Test
-    public void serializeTest() {
-        input = createMatchEntry();
-        nsiCodec.serialize(input, buffer);
-
-        assertEquals(OxmMatchConstants.NXM_1_CLASS, buffer.readUnsignedShort());
-        short fieldMask = buffer.readUnsignedByte();
-        assertEquals(NXM_FIELD_CODE, fieldMask >> 1);
-        assertEquals(0, fieldMask & 1);
-        assertEquals(VALUE_LENGTH, buffer.readUnsignedByte());
-        assertEquals(1, buffer.readUnsignedByte());
+    public void serializeTestNoMask() {
+        NxExpMatchEntryValue matchEntryValue = createMatchEntryValue(NSI_VALUE, null);
+
+        nsiCodec.serializeValue(matchEntryValue, false, buffer);
+
+        assertEquals(NSI_VALUE.shortValue(), buffer.readUnsignedByte());
+        assertFalse(buffer.isReadable());
     }
 
     @Test
-    public void deserializeTest() {
-        createBuffer(buffer);
+    public void serializeTestMask() {
+        NxExpMatchEntryValue matchEntryValue = createMatchEntryValue(NSI_VALUE, NSI_MASK);
 
-        input = nsiCodec.deserialize(buffer);
+        nsiCodec.serializeValue(matchEntryValue, true, buffer);
 
-        final NsiCaseValue result = (NsiCaseValue) input.getMatchEntryValue();
-
-        assertEquals(Nxm1Class.class, input.getOxmClass());
-        assertEquals(NxmNxNsi.class, input.getOxmMatchField());
-        assertEquals(false, input.isHasMask());
-        assertEquals(2, result.getNsiValues().getNsi().shortValue());
+        assertEquals(NSI_VALUE.shortValue(), buffer.readUnsignedByte());
+        assertEquals(NSI_MASK.shortValue(), buffer.readUnsignedByte());
+        assertFalse(buffer.isReadable());
     }
 
+    @Test
+    public void deserializeTestNoMask() {
+        writeBuffer(buffer, NSI_VALUE, null);
+
+        NxExpMatchEntryValue value = nsiCodec.deserializeValue(buffer, false);
 
-    private MatchEntry createMatchEntry() {
-        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-        final NsiCaseValueBuilder caseBuilder = new NsiCaseValueBuilder();
-        final NsiValuesBuilder valuesBuilder = new NsiValuesBuilder();
+        assertEquals(NSI_VALUE, ((NsiCaseValue) value).getNsiValues().getNsi());
+        assertFalse(buffer.isReadable());
+    }
 
-        matchEntryBuilder.setOxmClass(Nxm1Class.class);
-        matchEntryBuilder.setOxmMatchField(NxmNxNsi.class);
-        matchEntryBuilder.setHasMask(false);
+    @Test
+    public void deserializeTestMask() {
+        writeBuffer(buffer, NSI_VALUE, NSI_MASK);
 
-        valuesBuilder.setNsi((short)1);
+        NxExpMatchEntryValue value = nsiCodec.deserializeValue(buffer, true);
 
-        caseBuilder.setNsiValues(valuesBuilder.build());
-        matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
-        return matchEntryBuilder.build();
+        assertEquals(NSI_VALUE, ((NsiCaseValue) value).getNsiValues().getNsi());
+        assertEquals(NSI_MASK, ((NsiCaseValue) value).getNsiValues().getMask());
+        assertFalse(buffer.isReadable());
     }
 
-    private void createBuffer(ByteBuf message) {
-        message.writeShort(OxmMatchConstants.NXM_1_CLASS);
+    private NxExpMatchEntryValue createMatchEntryValue(Short value, Short mask) {
+        NsiValues nsiValues = new NsiValuesBuilder().setNsi(value).setMask(mask).build();
+        return new NsiCaseValueBuilder().setNsiValues(nsiValues).build();
+    }
 
-        int fieldMask = NXM_FIELD_CODE << 1;
-        message.writeByte(fieldMask);
-        message.writeByte(VALUE_LENGTH);
-        message.writeByte(2);
+    private void writeBuffer(ByteBuf message, Short value, Short mask) {
+        message.writeByte(value.intValue());
+        if (mask != null) {
+            message.writeByte(mask.intValue());
+        }
     }
 }
index e2e84b6d162eb4f09338adb1f23ff48155a0b9af..a6f70aa57ad3340877f67aefef29111f65849238 100644 (file)
@@ -9,28 +9,25 @@
 package org.opendaylight.openflowjava.nx.codec.match;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.ByteBufAllocator;
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
-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.nx.match.rev140421.NxmNxNsp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsp.grouping.NspValues;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsp.grouping.NspValuesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.NspCaseValue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.NspCaseValueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NspCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NspCaseValueBuilder;
 
 public class NspCodecTest {
 
-    NspCodec nspCodec;
-    ByteBuf buffer;
-    MatchEntry input;
+    private NspCodec nspCodec;
+    private ByteBuf buffer;
 
-    private static final int VALUE_LENGTH = 4;
-    private static final int NXM_FIELD_CODE = 113;
+    private static final Long NSP_VALUE = 10L;
+    private static final Long NSP_MASK = 0xFL;
 
     @Before
     public void setUp() {
@@ -39,55 +36,57 @@ public class NspCodecTest {
     }
 
     @Test
-    public void serializeTest() {
-        input = createMatchEntry();
-        nspCodec.serialize(input, buffer);
-
-        assertEquals(OxmMatchConstants.NXM_1_CLASS, buffer.readUnsignedShort());
-        short fieldMask = buffer.readUnsignedByte();
-        assertEquals(NXM_FIELD_CODE, fieldMask >> 1);
-        assertEquals(0, fieldMask & 1);
-        assertEquals(VALUE_LENGTH, buffer.readUnsignedByte());
-        assertEquals(1, buffer.readUnsignedInt());
+    public void serializeTestNoMask() {
+        NxExpMatchEntryValue matchEntryValue = createMatchEntryValue(NSP_VALUE, null);
+
+        nspCodec.serializeValue(matchEntryValue, false, buffer);
+
+        assertEquals(NSP_VALUE.longValue(), buffer.readUnsignedInt());
+        assertFalse(buffer.isReadable());
     }
 
     @Test
-    public void deserializeTest() {
-        createBuffer(buffer);
-
-        input = nspCodec.deserialize(buffer);
+    public void serializeTestMask() {
+        NxExpMatchEntryValue matchEntryValue = createMatchEntryValue(NSP_VALUE, NSP_MASK);
 
-        final NspCaseValue result = (NspCaseValue) input.getMatchEntryValue();
+        nspCodec.serializeValue(matchEntryValue, true, buffer);
 
-        assertEquals(Nxm1Class.class, input.getOxmClass());
-        assertEquals(NxmNxNsp.class, input.getOxmMatchField());
-        assertEquals(false, input.isHasMask());
-        assertEquals(2, result.getNspValues().getNsp().intValue());
+        assertEquals(NSP_VALUE.longValue(), buffer.readUnsignedInt());
+        assertEquals(NSP_MASK.longValue(), buffer.readUnsignedInt());
+        assertFalse(buffer.isReadable());
     }
 
+    @Test
+    public void deserializeTestNoMask() {
+        writeBuffer(buffer, NSP_VALUE, null);
 
-    private MatchEntry createMatchEntry() {
-        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-        final NspCaseValueBuilder caseBuilder = new NspCaseValueBuilder();
-        final NspValuesBuilder valuesBuilder = new NspValuesBuilder();
+        NxExpMatchEntryValue value = nspCodec.deserializeValue(buffer, false);
 
-        matchEntryBuilder.setOxmClass(Nxm1Class.class);
-        matchEntryBuilder.setOxmMatchField(NxmNxNsp.class);
-        matchEntryBuilder.setHasMask(false);
+        assertEquals(NSP_VALUE, ((NspCaseValue) value).getNspValues().getNsp());
+        assertFalse(buffer.isReadable());
+    }
 
-        valuesBuilder.setNsp((long)1);
+    @Test
+    public void deserializeTestMask() {
+        writeBuffer(buffer, NSP_VALUE, NSP_MASK);
+
+        NxExpMatchEntryValue value = nspCodec.deserializeValue(buffer, true);
 
-        caseBuilder.setNspValues(valuesBuilder.build());
-        matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
-        return matchEntryBuilder.build();
+        assertEquals(NSP_VALUE, ((NspCaseValue) value).getNspValues().getNsp());
+        assertEquals(NSP_MASK, ((NspCaseValue) value).getNspValues().getMask());
+        assertFalse(buffer.isReadable());
     }
 
-    private void createBuffer(ByteBuf message) {
-        message.writeShort(OxmMatchConstants.NXM_1_CLASS);
 
-        int fieldMask = NXM_FIELD_CODE << 1;
-        message.writeByte(fieldMask);
-        message.writeByte(VALUE_LENGTH);
-        message.writeInt(2);
+    private NxExpMatchEntryValue createMatchEntryValue(Long value, Long mask) {
+        NspValues nspValues = new NspValuesBuilder().setNsp(value).setMask(mask).build();
+        return new NspCaseValueBuilder().setNspValues(nspValues).build();
+    }
+
+    private void writeBuffer(ByteBuf message, Long value, Long mask) {
+        message.writeInt(value.intValue());
+        if (mask != null) {
+            message.writeInt(mask.intValue());
+        }
     }
 }
index 7060f520f32a8a62b3ae4a7f2ef76b3ef2ee4a63..2955d987b0673508f9bd5750e520940de1d76f37 100644 (file)
@@ -19,25 +19,57 @@ import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
 import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.CodecPreconditionException;
 import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match.NshFlagsConvertor;
 import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match.NshTtlConvertor;
+import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match.Nshc1Convertor;
+import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match.Nshc2Convertor;
+import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match.Nshc3Convertor;
+import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match.Nshc4Convertor;
+import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match.NsiConvertor;
+import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match.NspConvertor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionRegLoad2;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionRegLoad2Builder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.reg.load2.grouping.NxActionRegLoad2;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.reg.load2.grouping.NxActionRegLoad2Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNshFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNshTtl;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNshc1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNshc2;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNshc3;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNshc4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNsi;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNsp;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.OfjAugNxExpMatch;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsh.flags.grouping.NshFlagsValues;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsh.ttl.grouping.NshTtlValues;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsi.grouping.NsiValues;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsp.grouping.NspValues;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshFlagsCaseValue;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshTtlCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshcCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NsiCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NspCaseValue;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.NxActionRegLoadGrouping;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.DstChoice;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshFlagsCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshFlagsCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshTtlCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc1Case;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc1CaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc2Case;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc2CaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc3Case;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc3CaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc4Case;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc4CaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNsiCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNsiCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNspCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNspCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.NxRegLoad;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.NxRegLoadBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.nx.reg.load.Dst;
@@ -87,32 +119,95 @@ public class RegLoad2Convertor implements
     }
 
     private static MatchEntry resolveMatchEntry(DstChoice dstChoice, BigInteger value, BigInteger mask) {
-        if (dstChoice instanceof DstNxNshFlagsCase) {
-            return NshFlagsConvertor.buildMatchEntry(value.shortValue(), mask.shortValue());
-        }
-        if (dstChoice instanceof DstNxNshTtlCase) {
-            return NshTtlConvertor.buildMatchEntry(value.shortValue(), mask.shortValue());
+        try {
+            if (dstChoice instanceof DstNxNshFlagsCase) {
+                return NshFlagsConvertor.buildMatchEntry(value.shortValueExact(), mask.shortValueExact());
+            }
+            if (dstChoice instanceof DstNxNspCase) {
+                return NspConvertor.buildMatchEntry(value.longValueExact(), mask.longValueExact());
+            }
+            if (dstChoice instanceof DstNxNsiCase) {
+                return NsiConvertor.buildMatchEntry(value.shortValueExact(), mask.shortValueExact());
+            }
+            if (dstChoice instanceof DstNxNshc1Case) {
+                return Nshc1Convertor.buildMatchEntry(value.longValueExact(), mask.longValueExact());
+            }
+            if (dstChoice instanceof DstNxNshc2Case) {
+                return Nshc2Convertor.buildMatchEntry(value.longValueExact(), mask.longValueExact());
+            }
+            if (dstChoice instanceof DstNxNshc3Case) {
+                return Nshc3Convertor.buildMatchEntry(value.longValueExact(), mask.longValueExact());
+            }
+            if (dstChoice instanceof DstNxNshc4Case) {
+                return Nshc4Convertor.buildMatchEntry(value.longValueExact(), mask.longValueExact());
+            }
+            if (dstChoice instanceof DstNxNshTtlCase) {
+                return NshTtlConvertor.buildMatchEntry(value.shortValueExact(), mask.shortValueExact());
+            }
+        } catch (ArithmeticException e) {
+            throw new IllegalArgumentException("Value or bit range too big for destination choice", e);
         }
 
         throw new CodecPreconditionException("Missing implementation of a case in dst-choice? " + dstChoice.getClass());
     }
 
     private static NxRegLoad resolveRegLoad(MatchEntry matchEntry) {
+        Class<? extends MatchField> oxmMatchField = matchEntry.getOxmMatchField();
         ExperimenterIdCase experimenterIdCase = (ExperimenterIdCase) matchEntry.getMatchEntryValue();
         OfjAugNxExpMatch ofjAugNxExpMatch = experimenterIdCase.augmentation(OfjAugNxExpMatch.class);
         NxExpMatchEntryValue nxExpMatchEntryValue = ofjAugNxExpMatch.getNxExpMatchEntryValue();
         DstBuilder dstBuilder = new DstBuilder();
-        return resolveRegLoad(nxExpMatchEntryValue, dstBuilder);
+        return resolveRegLoad(oxmMatchField, nxExpMatchEntryValue, dstBuilder);
     }
 
-    private static NxRegLoad resolveRegLoad(NxExpMatchEntryValue value, DstBuilder dstBuilder) {
-        if (value instanceof NshFlagsCaseValue) {
+    private static NxRegLoad resolveRegLoad(
+            Class<? extends MatchField> oxmMatchField,
+            NxExpMatchEntryValue value,
+            DstBuilder dstBuilder) {
+
+        if (NxmNxNshFlags.class.equals(oxmMatchField)) {
             int valueLength = NiciraMatchCodecs.NSH_FLAGS_CODEC.getValueLength();
             dstBuilder.setDstChoice(new DstNxNshFlagsCaseBuilder().setNxNshFlags(true).build());
             NshFlagsValues nshFlagsValues = ((NshFlagsCaseValue) value).getNshFlagsValues();
             return resolveRegLoad(nshFlagsValues.getNshFlags(), nshFlagsValues.getMask(), valueLength, dstBuilder);
         }
-        if (value instanceof NshTtlCaseValue) {
+        if (NxmNxNsp.class.equals(oxmMatchField)) {
+            int valueLength = NiciraMatchCodecs.NSP_CODEC.getValueLength();
+            dstBuilder.setDstChoice(new DstNxNspCaseBuilder().setNxNspDst(true).build());
+            NspValues nspValues = ((NspCaseValue) value).getNspValues();
+            return resolveRegLoad(nspValues.getNsp(), nspValues.getMask(), valueLength, dstBuilder);
+        }
+        if (NxmNxNsi.class.equals(oxmMatchField)) {
+            int valueLength = NiciraMatchCodecs.NSI_CODEC.getValueLength();
+            dstBuilder.setDstChoice(new DstNxNsiCaseBuilder().setNxNsiDst(true).build());
+            NsiValues nsiValues = ((NsiCaseValue) value).getNsiValues();
+            return resolveRegLoad(nsiValues.getNsi(), nsiValues.getMask(), valueLength, dstBuilder);
+        }
+        if (NxmNxNshc1.class.equals(oxmMatchField)) {
+            int valueLength = NiciraMatchCodecs.NSC1_CODEC.getValueLength();
+            dstBuilder.setDstChoice(new DstNxNshc1CaseBuilder().setNxNshc1Dst(true).build());
+            NshcCaseValue nshcCaseValue = ((NshcCaseValue) value);
+            return resolveRegLoad(nshcCaseValue.getNshc(), nshcCaseValue.getMask(), valueLength, dstBuilder);
+        }
+        if (NxmNxNshc2.class.equals(oxmMatchField)) {
+            int valueLength = NiciraMatchCodecs.NSC2_CODEC.getValueLength();
+            dstBuilder.setDstChoice(new DstNxNshc2CaseBuilder().setNxNshc2Dst(true).build());
+            NshcCaseValue nshcCaseValue = ((NshcCaseValue) value);
+            return resolveRegLoad(nshcCaseValue.getNshc(), nshcCaseValue.getMask(), valueLength, dstBuilder);
+        }
+        if (NxmNxNshc3.class.equals(oxmMatchField)) {
+            int valueLength = NiciraMatchCodecs.NSC3_CODEC.getValueLength();
+            dstBuilder.setDstChoice(new DstNxNshc3CaseBuilder().setNxNshc3Dst(true).build());
+            NshcCaseValue nshcCaseValue = ((NshcCaseValue) value);
+            return resolveRegLoad(nshcCaseValue.getNshc(), nshcCaseValue.getMask(), valueLength, dstBuilder);
+        }
+        if (NxmNxNshc4.class.equals(oxmMatchField)) {
+            int valueLength = NiciraMatchCodecs.NSC4_CODEC.getValueLength();
+            dstBuilder.setDstChoice(new DstNxNshc4CaseBuilder().setNxNshc4Dst(true).build());
+            NshcCaseValue nshcCaseValue = ((NshcCaseValue) value);
+            return resolveRegLoad(nshcCaseValue.getNshc(), nshcCaseValue.getMask(), valueLength, dstBuilder);
+        }
+        if (NxmNxNshTtl.class.equals(oxmMatchField)) {
             int valueLength = NiciraMatchCodecs.NSH_TTL_CODEC.getValueLength();
             dstBuilder.setDstChoice(new DstNxNshTtlCaseBuilder().setNxNshTtl(true).build());
             NshTtlValues nshTtlValues = ((NshTtlCaseValue) value).getNshTtlValues();
@@ -122,7 +217,15 @@ public class RegLoad2Convertor implements
         throw new CodecPreconditionException("Missing codec for " + value.getImplementedInterface());
     }
 
-    private static NxRegLoad resolveRegLoad(Short value, Short mask, int valueLength, DstBuilder dstBuilder) {
+    private static NxRegLoad resolveRegLoad(Short value, @Nullable Short mask, int valueLength, DstBuilder dstBuilder) {
+        return resolveRegLoad(
+                BigInteger.valueOf(value),
+                mask == null ? null : BigInteger.valueOf(mask),
+                valueLength,
+                dstBuilder);
+    }
+
+    private static NxRegLoad resolveRegLoad(Long value, @Nullable Long mask, int valueLength, DstBuilder dstBuilder) {
         return resolveRegLoad(
                 BigInteger.valueOf(value),
                 mask == null ? null : BigInteger.valueOf(mask),
@@ -130,6 +233,8 @@ public class RegLoad2Convertor implements
                 dstBuilder);
     }
 
+    // Convert the value/mask pair of the openflowjava reg_load2 action to the
+    // value/bit range pair of the openfloplugin reg_load action.
     private static NxRegLoad resolveRegLoad(BigInteger value,
                                             @Nullable BigInteger mask,
                                             int length,
@@ -159,6 +264,8 @@ public class RegLoad2Convertor implements
         return nxRegLoadBuilder.build();
     }
 
+    // Convert value/bit range pair of the openfloplugin reg_load action to the
+    // value/mask pair of the openflowjava reg_load2 action.
     private static BigInteger[] resolveValueMask(BigInteger value, int start, int end) {
         int bits = end - start + 1;
         if (value.bitLength() > bits) {
index d6fc5fdd3d53b1e6dc119a073f376416434a02fa..4f7a22289e0521bf7d281fac651230f3bab25ad3 100644 (file)
@@ -9,16 +9,20 @@
 package org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match;
 
 import com.google.common.base.Optional;
+import org.opendaylight.openflowjava.nx.api.NiciraConstants;
 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.nicira.convertor.CodecPreconditionException;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.OfjAugNxExpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsh.mdtype.grouping.NshMdtypeValues;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsh.mdtype.grouping.NshMdtypeValuesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.NshMdtypeCaseValue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.NshMdtypeCaseValueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshMdtypeCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshMdtypeCaseValueBuilder;
 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.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow;
@@ -38,12 +42,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni
 import org.opendaylight.yangtools.yang.binding.Augmentation;
 
 public class NshMdtypeConvertor implements ConvertorToOFJava<MatchEntry>, ConvertorFromOFJava<MatchEntry, MatchPath> {
+
     @Override
     public ExtensionAugment<? extends Augmentation<Extension>> convert(MatchEntry input, MatchPath path) {
-        NshMdtypeCaseValue nshMdtypeCaseValue = (NshMdtypeCaseValue) input.getMatchEntryValue();
-
+        ExperimenterIdCase experimenterIdCase = (ExperimenterIdCase) input.getMatchEntryValue();
+        OfjAugNxExpMatch ofjAugNxExpMatch = experimenterIdCase.augmentation(OfjAugNxExpMatch.class);
+        NshMdtypeCaseValue nshMdtypeCaseValue = (NshMdtypeCaseValue) ofjAugNxExpMatch.getNxExpMatchEntryValue();
+        NshMdtypeValues nshMdtypeValues = nshMdtypeCaseValue.getNshMdtypeValues();
+        NxmNxNshMdtype nxmNxNshMdtype = new NxmNxNshMdtypeBuilder()
+                .setValue(nshMdtypeValues.getValue())
+                .build();
         return resolveAugmentation(
-                new NxmNxNshMdtypeBuilder().setValue(nshMdtypeCaseValue.getNshMdtypeValues().getValue()).build(), path,
+                nxmNxNshMdtype,
+                path,
                 NxmNxNshMdtypeKey.class);
     }
 
@@ -54,15 +65,20 @@ public class NshMdtypeConvertor implements ConvertorToOFJava<MatchEntry>, Conver
             throw new CodecPreconditionException(extension);
         }
         Short value = matchGrouping.get().getNxmNxNshMdtype().getValue();
-        NshMdtypeCaseValueBuilder nshMdtypeCaseValueBuilder = new NshMdtypeCaseValueBuilder();
-        nshMdtypeCaseValueBuilder.setNshMdtypeValues(new NshMdtypeValuesBuilder()
-                .setValue(value).build());
-        return MatchUtil.createDefaultMatchEntryBuilder(
+        return buildMatchEntry(value, null);
+    }
+
+    public static MatchEntry buildMatchEntry(Short value, Short mask) {
+        NshMdtypeValues nshMdtypeValues = new NshMdtypeValuesBuilder().setValue(value).build();
+        NxExpMatchEntryValue entryValue = new NshMdtypeCaseValueBuilder().setNshMdtypeValues(nshMdtypeValues).build();
+        return MatchUtil.createExperimenterMatchEntryBuilder(
                 org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNshMdtype.class,
-                Nxm1Class.class, nshMdtypeCaseValueBuilder.build()).build();
+                NiciraConstants.NX_NSH_VENDOR_ID,
+                entryValue).setHasMask(mask != null).build();
     }
 
-    private static ExtensionAugment<? extends Augmentation<Extension>> resolveAugmentation(NxmNxNshMdtype value,
+    private static ExtensionAugment<? extends Augmentation<Extension>> resolveAugmentation(
+            NxmNxNshMdtype value,
             MatchPath path, Class<? extends ExtensionKey> key) {
         switch (path) {
             case FLOWS_STATISTICS_UPDATE_MATCH:
@@ -72,8 +88,8 @@ public class NshMdtypeConvertor implements ConvertorToOFJava<MatchEntry>, Conver
                 return new ExtensionAugment<>(NxAugMatchRpcGetFlowStats.class,
                         new NxAugMatchRpcGetFlowStatsBuilder().setNxmNxNshMdtype(value).build(), key);
             case PACKET_RECEIVED_MATCH:
-                return new ExtensionAugment<>(NxAugMatchNotifPacketIn.class, new NxAugMatchNotifPacketInBuilder()
-                        .setNxmNxNshMdtype(value).build(), key);
+                return new ExtensionAugment<>(NxAugMatchNotifPacketIn.class,
+                        new NxAugMatchNotifPacketInBuilder().setNxmNxNshMdtype(value).build(), key);
             case SWITCH_FLOW_REMOVED_MATCH:
                 return new ExtensionAugment<>(NxAugMatchNotifSwitchFlowRemoved.class,
                         new NxAugMatchNotifSwitchFlowRemovedBuilder().setNxmNxNshMdtype(value).build(), key);
index e0c7227d3569872ac3104a93cde89c1ba1e46ab8..fdb030555156018c27a52b5098d20d800d3ff7fd 100644 (file)
@@ -9,16 +9,20 @@
 package org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match;
 
 import com.google.common.base.Optional;
+import org.opendaylight.openflowjava.nx.api.NiciraConstants;
 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.nicira.convertor.CodecPreconditionException;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.OfjAugNxExpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsh.np.grouping.NshNpValues;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsh.np.grouping.NshNpValuesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.NshNpCaseValue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.NshNpCaseValueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshNpCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshNpCaseValueBuilder;
 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.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow;
@@ -38,12 +42,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni
 import org.opendaylight.yangtools.yang.binding.Augmentation;
 
 public class NshNpConvertor implements ConvertorToOFJava<MatchEntry>, ConvertorFromOFJava<MatchEntry, MatchPath> {
+
     @Override
     public ExtensionAugment<? extends Augmentation<Extension>> convert(MatchEntry input, MatchPath path) {
-        NshNpCaseValue nshNpCaseValue = (NshNpCaseValue) input.getMatchEntryValue();
-
-        return resolveAugmentation(new NxmNxNshNpBuilder().setValue(nshNpCaseValue.getNshNpValues().getValue()).build(),
-                path, NxmNxNshNpKey.class);
+        ExperimenterIdCase experimenterIdCase = (ExperimenterIdCase) input.getMatchEntryValue();
+        OfjAugNxExpMatch ofjAugNxExpMatch = experimenterIdCase.augmentation(OfjAugNxExpMatch.class);
+        NshNpCaseValue nshNpCaseValue = (NshNpCaseValue) ofjAugNxExpMatch.getNxExpMatchEntryValue();
+        NshNpValues nshNpValues = nshNpCaseValue.getNshNpValues();
+        NxmNxNshNp nxmNxNshNp = new NxmNxNshNpBuilder()
+                .setValue(nshNpValues.getValue())
+                .build();
+        return resolveAugmentation(
+                nxmNxNshNp,
+                path,
+                NxmNxNshNpKey.class);
     }
 
     @Override
@@ -53,15 +65,20 @@ public class NshNpConvertor implements ConvertorToOFJava<MatchEntry>, ConvertorF
             throw new CodecPreconditionException(extension);
         }
         Short value = matchGrouping.get().getNxmNxNshNp().getValue();
-        NshNpCaseValueBuilder nshNpCaseValueBuilder = new NshNpCaseValueBuilder();
-        nshNpCaseValueBuilder.setNshNpValues(new NshNpValuesBuilder()
-                .setValue(value).build());
-        return MatchUtil.createDefaultMatchEntryBuilder(
+        return buildMatchEntry(value, null);
+    }
+
+    public static MatchEntry buildMatchEntry(Short value, Short mask) {
+        NshNpValues nshNpValues = new NshNpValuesBuilder().setValue(value).build();
+        NxExpMatchEntryValue entryValue = new NshNpCaseValueBuilder().setNshNpValues(nshNpValues).build();
+        return MatchUtil.createExperimenterMatchEntryBuilder(
                 org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNshNp.class,
-                Nxm1Class.class, nshNpCaseValueBuilder.build()).build();
+                NiciraConstants.NX_NSH_VENDOR_ID,
+                entryValue).setHasMask(mask != null).build();
     }
 
-    private static ExtensionAugment<? extends Augmentation<Extension>> resolveAugmentation(NxmNxNshNp value,
+    private static ExtensionAugment<? extends Augmentation<Extension>> resolveAugmentation(
+            NxmNxNshNp value,
             MatchPath path, Class<? extends ExtensionKey> key) {
         switch (path) {
             case FLOWS_STATISTICS_UPDATE_MATCH:
@@ -71,8 +88,8 @@ public class NshNpConvertor implements ConvertorToOFJava<MatchEntry>, ConvertorF
                 return new ExtensionAugment<>(NxAugMatchRpcGetFlowStats.class,
                         new NxAugMatchRpcGetFlowStatsBuilder().setNxmNxNshNp(value).build(), key);
             case PACKET_RECEIVED_MATCH:
-                return new ExtensionAugment<>(NxAugMatchNotifPacketIn.class, new NxAugMatchNotifPacketInBuilder()
-                        .setNxmNxNshNp(value).build(), key);
+                return new ExtensionAugment<>(NxAugMatchNotifPacketIn.class,
+                        new NxAugMatchNotifPacketInBuilder().setNxmNxNshNp(value).build(), key);
             case SWITCH_FLOW_REMOVED_MATCH:
                 return new ExtensionAugment<>(NxAugMatchNotifSwitchFlowRemoved.class,
                         new NxAugMatchNotifSwitchFlowRemovedBuilder().setNxmNxNshNp(value).build(), key);
index d0e277cdb30ff911988857e7f155ca6643b4826d..cbb7288a8a6100c53834dd6c3c08e380a0799186 100644 (file)
@@ -8,16 +8,17 @@
 package org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match;
 
 import com.google.common.base.Optional;
+import org.opendaylight.openflowjava.nx.api.NiciraConstants;
 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.nicira.convertor.CodecPreconditionException;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nshc._1.grouping.Nshc1ValuesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc1CaseValue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc1CaseValueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.OfjAugNxExpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshcCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshcCaseValueBuilder;
 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.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow;
@@ -37,12 +38,17 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni
 import org.opendaylight.yangtools.yang.binding.Augmentation;
 
 public class Nshc1Convertor implements ConvertorToOFJava<MatchEntry>, ConvertorFromOFJava<MatchEntry, MatchPath> {
+
     @Override
     public ExtensionAugment<? extends Augmentation<Extension>> convert(MatchEntry input, MatchPath path) {
-        Nshc1CaseValue nsc1CaseValue = (Nshc1CaseValue) input.getMatchEntryValue();
-
-        return resolveAugmentation(new NxmNxNshc1Builder().setValue(nsc1CaseValue.getNshc1Values().getNshc()).build(),
-                path, NxmNxNshc1Key.class);
+        ExperimenterIdCase experimenterIdCase = (ExperimenterIdCase) input.getMatchEntryValue();
+        OfjAugNxExpMatch ofjAugNxExpMatch = experimenterIdCase.augmentation(OfjAugNxExpMatch.class);
+        NshcCaseValue nshcCaseValue = (NshcCaseValue) ofjAugNxExpMatch.getNxExpMatchEntryValue();
+        NxmNxNshc1 nxmNxNshc1 = new NxmNxNshc1Builder()
+                .setValue(nshcCaseValue.getNshc())
+                .setMask(nshcCaseValue.getMask())
+                .build();
+        return resolveAugmentation(nxmNxNshc1, path, NxmNxNshc1Key.class);
     }
 
     @Override
@@ -52,15 +58,21 @@ public class Nshc1Convertor implements ConvertorToOFJava<MatchEntry>, ConvertorF
             throw new CodecPreconditionException(extension);
         }
         Long value = matchGrouping.get().getNxmNxNshc1().getValue();
-        Nshc1CaseValueBuilder nsc1CaseValueBuilder = new Nshc1CaseValueBuilder();
-        nsc1CaseValueBuilder.setNshc1Values(new Nshc1ValuesBuilder()
-                .setNshc(value).build());
-        return MatchUtil.createDefaultMatchEntryBuilder(
+        Long mask = matchGrouping.get().getNxmNxNshc1().getMask();
+        MatchEntry matchEntry = buildMatchEntry(value, mask);
+        return matchEntry;
+    }
+
+    public static MatchEntry buildMatchEntry(Long value, Long mask) {
+        NshcCaseValue nshcCaseValue = new NshcCaseValueBuilder().setNshc(value).setMask(mask).build();
+        return MatchUtil.createExperimenterMatchEntryBuilder(
                 org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNshc1.class,
-                Nxm1Class.class, nsc1CaseValueBuilder.build()).build();
+                NiciraConstants.NX_NSH_VENDOR_ID,
+                nshcCaseValue).setHasMask(mask != null).build();
     }
 
-    private static ExtensionAugment<? extends Augmentation<Extension>> resolveAugmentation(NxmNxNshc1 value,
+    private static ExtensionAugment<? extends Augmentation<Extension>> resolveAugmentation(
+            NxmNxNshc1 value,
             MatchPath path, Class<? extends ExtensionKey> key) {
         switch (path) {
             case FLOWS_STATISTICS_UPDATE_MATCH:
index f27174571bd568135a70d62dc7e528671b5a5dc9..fdf894d7a6f477bd7fc604bbc7fd205e7340eb37 100644 (file)
@@ -8,16 +8,17 @@
 package org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match;
 
 import com.google.common.base.Optional;
+import org.opendaylight.openflowjava.nx.api.NiciraConstants;
 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.nicira.convertor.CodecPreconditionException;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nshc._2.grouping.Nshc2ValuesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc2CaseValue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc2CaseValueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.OfjAugNxExpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshcCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshcCaseValueBuilder;
 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.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow;
@@ -37,12 +38,17 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni
 import org.opendaylight.yangtools.yang.binding.Augmentation;
 
 public class Nshc2Convertor implements ConvertorToOFJava<MatchEntry>, ConvertorFromOFJava<MatchEntry, MatchPath> {
+
     @Override
     public ExtensionAugment<? extends Augmentation<Extension>> convert(MatchEntry input, MatchPath path) {
-        Nshc2CaseValue nsc2CaseValue = (Nshc2CaseValue) input.getMatchEntryValue();
-
-        return resolveAugmentation(new NxmNxNshc2Builder().setValue(nsc2CaseValue.getNshc2Values().getNshc()).build(),
-                path, NxmNxNshc2Key.class);
+        ExperimenterIdCase experimenterIdCase = (ExperimenterIdCase) input.getMatchEntryValue();
+        OfjAugNxExpMatch ofjAugNxExpMatch = experimenterIdCase.augmentation(OfjAugNxExpMatch.class);
+        NshcCaseValue nshcCaseValue = (NshcCaseValue) ofjAugNxExpMatch.getNxExpMatchEntryValue();
+        NxmNxNshc2 nxmNxNshc2 = new NxmNxNshc2Builder()
+                .setValue(nshcCaseValue.getNshc())
+                .setMask(nshcCaseValue.getMask())
+                .build();
+        return resolveAugmentation(nxmNxNshc2, path, NxmNxNshc2Key.class);
     }
 
     @Override
@@ -52,15 +58,21 @@ public class Nshc2Convertor implements ConvertorToOFJava<MatchEntry>, ConvertorF
             throw new CodecPreconditionException(extension);
         }
         Long value = matchGrouping.get().getNxmNxNshc2().getValue();
-        Nshc2CaseValueBuilder nsc2CaseValueBuilder = new Nshc2CaseValueBuilder();
-        nsc2CaseValueBuilder.setNshc2Values(new Nshc2ValuesBuilder()
-                .setNshc(value).build());
-        return MatchUtil.createDefaultMatchEntryBuilder(
+        Long mask = matchGrouping.get().getNxmNxNshc2().getMask();
+        MatchEntry matchEntry = buildMatchEntry(value, mask);
+        return matchEntry;
+    }
+
+    public static MatchEntry buildMatchEntry(Long value, Long mask) {
+        NshcCaseValue nshcCaseValue = new NshcCaseValueBuilder().setNshc(value).setMask(mask).build();
+        return MatchUtil.createExperimenterMatchEntryBuilder(
                 org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNshc2.class,
-                Nxm1Class.class, nsc2CaseValueBuilder.build()).build();
+                NiciraConstants.NX_NSH_VENDOR_ID,
+                nshcCaseValue).setHasMask(mask != null).build();
     }
 
-    private static ExtensionAugment<? extends Augmentation<Extension>> resolveAugmentation(NxmNxNshc2 value,
+    private static ExtensionAugment<? extends Augmentation<Extension>> resolveAugmentation(
+            NxmNxNshc2 value,
             MatchPath path, Class<? extends ExtensionKey> key) {
         switch (path) {
             case FLOWS_STATISTICS_UPDATE_MATCH:
index d5673573bce3e884653a313054ee4de186eab64a..89bb0e7ce9ce0d7c25f0e41df6d52b709b90be8f 100644 (file)
@@ -8,16 +8,17 @@
 package org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match;
 
 import com.google.common.base.Optional;
+import org.opendaylight.openflowjava.nx.api.NiciraConstants;
 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.nicira.convertor.CodecPreconditionException;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nshc._3.grouping.Nshc3ValuesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc3CaseValue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc3CaseValueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.OfjAugNxExpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshcCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshcCaseValueBuilder;
 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.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow;
@@ -37,12 +38,17 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni
 import org.opendaylight.yangtools.yang.binding.Augmentation;
 
 public class Nshc3Convertor implements ConvertorToOFJava<MatchEntry>, ConvertorFromOFJava<MatchEntry, MatchPath> {
+
     @Override
     public ExtensionAugment<? extends Augmentation<Extension>> convert(MatchEntry input, MatchPath path) {
-        Nshc3CaseValue nsc3CaseValue = (Nshc3CaseValue) input.getMatchEntryValue();
-
-        return resolveAugmentation(new NxmNxNshc3Builder().setValue(nsc3CaseValue.getNshc3Values().getNshc()).build(),
-                path, NxmNxNshc3Key.class);
+        ExperimenterIdCase experimenterIdCase = (ExperimenterIdCase) input.getMatchEntryValue();
+        OfjAugNxExpMatch ofjAugNxExpMatch = experimenterIdCase.augmentation(OfjAugNxExpMatch.class);
+        NshcCaseValue nshcCaseValue = (NshcCaseValue) ofjAugNxExpMatch.getNxExpMatchEntryValue();
+        NxmNxNshc3 nxmNxNshc3 = new NxmNxNshc3Builder()
+                .setValue(nshcCaseValue.getNshc())
+                .setMask(nshcCaseValue.getMask())
+                .build();
+        return resolveAugmentation(nxmNxNshc3, path, NxmNxNshc3Key.class);
     }
 
     @Override
@@ -52,15 +58,21 @@ public class Nshc3Convertor implements ConvertorToOFJava<MatchEntry>, ConvertorF
             throw new CodecPreconditionException(extension);
         }
         Long value = matchGrouping.get().getNxmNxNshc3().getValue();
-        Nshc3CaseValueBuilder nsc3CaseValueBuilder = new Nshc3CaseValueBuilder();
-        nsc3CaseValueBuilder.setNshc3Values(new Nshc3ValuesBuilder()
-                .setNshc(value).build());
-        return MatchUtil.createDefaultMatchEntryBuilder(
+        Long mask = matchGrouping.get().getNxmNxNshc3().getMask();
+        MatchEntry matchEntry = buildMatchEntry(value, mask);
+        return matchEntry;
+    }
+
+    public static MatchEntry buildMatchEntry(Long value, Long mask) {
+        NshcCaseValue nshcCaseValue = new NshcCaseValueBuilder().setNshc(value).setMask(mask).build();
+        return MatchUtil.createExperimenterMatchEntryBuilder(
                 org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNshc3.class,
-                Nxm1Class.class, nsc3CaseValueBuilder.build()).build();
+                NiciraConstants.NX_NSH_VENDOR_ID,
+                nshcCaseValue).setHasMask(mask != null).build();
     }
 
-    private static ExtensionAugment<? extends Augmentation<Extension>> resolveAugmentation(NxmNxNshc3 value,
+    private static ExtensionAugment<? extends Augmentation<Extension>> resolveAugmentation(
+            NxmNxNshc3 value,
             MatchPath path, Class<? extends ExtensionKey> key) {
         switch (path) {
             case FLOWS_STATISTICS_UPDATE_MATCH:
index 41d846f7caa142811b3c887b3a0a541f6473b5db..eb9ac9414e4e6b8bab7487b414d7d71ae509c4e1 100644 (file)
@@ -8,16 +8,17 @@
 package org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match;
 
 import com.google.common.base.Optional;
+import org.opendaylight.openflowjava.nx.api.NiciraConstants;
 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.nicira.convertor.CodecPreconditionException;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nshc._4.grouping.Nshc4ValuesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc4CaseValue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc4CaseValueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.OfjAugNxExpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshcCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshcCaseValueBuilder;
 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.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow;
@@ -37,12 +38,17 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni
 import org.opendaylight.yangtools.yang.binding.Augmentation;
 
 public class Nshc4Convertor implements ConvertorToOFJava<MatchEntry>, ConvertorFromOFJava<MatchEntry, MatchPath> {
+
     @Override
     public ExtensionAugment<? extends Augmentation<Extension>> convert(MatchEntry input, MatchPath path) {
-        Nshc4CaseValue nsc4CaseValue = (Nshc4CaseValue) input.getMatchEntryValue();
-
-        return resolveAugmentation(new NxmNxNshc4Builder().setValue(nsc4CaseValue.getNshc4Values().getNshc()).build(),
-                path, NxmNxNshc4Key.class);
+        ExperimenterIdCase experimenterIdCase = (ExperimenterIdCase) input.getMatchEntryValue();
+        OfjAugNxExpMatch ofjAugNxExpMatch = experimenterIdCase.augmentation(OfjAugNxExpMatch.class);
+        NshcCaseValue nshcCaseValue = (NshcCaseValue) ofjAugNxExpMatch.getNxExpMatchEntryValue();
+        NxmNxNshc4 nxmNxNshc4 = new NxmNxNshc4Builder()
+                .setValue(nshcCaseValue.getNshc())
+                .setMask(nshcCaseValue.getMask())
+                .build();
+        return resolveAugmentation(nxmNxNshc4, path, NxmNxNshc4Key.class);
     }
 
     @Override
@@ -52,15 +58,21 @@ public class Nshc4Convertor implements ConvertorToOFJava<MatchEntry>, ConvertorF
             throw new CodecPreconditionException(extension);
         }
         Long value = matchGrouping.get().getNxmNxNshc4().getValue();
-        Nshc4CaseValueBuilder nsc4CaseValueBuilder = new Nshc4CaseValueBuilder();
-        nsc4CaseValueBuilder.setNshc4Values(new Nshc4ValuesBuilder()
-                .setNshc(value).build());
-        return MatchUtil.createDefaultMatchEntryBuilder(
+        Long mask = matchGrouping.get().getNxmNxNshc4().getMask();
+        MatchEntry matchEntry = buildMatchEntry(value, mask);
+        return matchEntry;
+    }
+
+    public static MatchEntry buildMatchEntry(Long value, Long mask) {
+        NshcCaseValue nshcCaseValue = new NshcCaseValueBuilder().setNshc(value).setMask(mask).build();
+        return MatchUtil.createExperimenterMatchEntryBuilder(
                 org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNshc4.class,
-                Nxm1Class.class, nsc4CaseValueBuilder.build()).build();
+                NiciraConstants.NX_NSH_VENDOR_ID,
+                nshcCaseValue).setHasMask(mask != null).build();
     }
 
-    private static ExtensionAugment<? extends Augmentation<Extension>> resolveAugmentation(NxmNxNshc4 value,
+    private static ExtensionAugment<? extends Augmentation<Extension>> resolveAugmentation(
+            NxmNxNshc4 value,
             MatchPath path, Class<? extends ExtensionKey> key) {
         switch (path) {
             case FLOWS_STATISTICS_UPDATE_MATCH:
index fed9736ec9d7bedf145cd3a30419d7a46099d8c6..95a9d139d723909e1d2ec0945067d39ce74e6b1c 100644 (file)
@@ -9,16 +9,19 @@
 package org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match;
 
 import com.google.common.base.Optional;
+import org.opendaylight.openflowjava.nx.api.NiciraConstants;
 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.nicira.convertor.CodecPreconditionException;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.OfjAugNxExpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsi.grouping.NsiValues;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsi.grouping.NsiValuesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.NsiCaseValue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.NsiCaseValueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NsiCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NsiCaseValueBuilder;
 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.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow;
@@ -40,8 +43,13 @@ import org.opendaylight.yangtools.yang.binding.Augmentation;
 public class NsiConvertor implements ConvertorToOFJava<MatchEntry>, ConvertorFromOFJava<MatchEntry, MatchPath> {
     @Override
     public ExtensionAugment<? extends Augmentation<Extension>> convert(MatchEntry input, MatchPath path) {
-        NsiCaseValue nsiCaseValue = (NsiCaseValue) input.getMatchEntryValue();
-        return resolveAugmentation(new NxmNxNsiBuilder().setNsi(nsiCaseValue.getNsiValues().getNsi()).build(), path,
+        ExperimenterIdCase experimenterIdCase = (ExperimenterIdCase) input.getMatchEntryValue();
+        OfjAugNxExpMatch ofjAugNxExpMatch = experimenterIdCase.augmentation(OfjAugNxExpMatch.class);
+        NsiCaseValue nshNsiCaseValue = (NsiCaseValue) ofjAugNxExpMatch.getNxExpMatchEntryValue();
+
+        return resolveAugmentation(
+                new NxmNxNsiBuilder().setNsi(nshNsiCaseValue.getNsiValues().getNsi()).build(),
+                path,
                 NxmNxNsiKey.class);
     }
 
@@ -51,14 +59,18 @@ public class NsiConvertor implements ConvertorToOFJava<MatchEntry>, ConvertorFro
         if (!matchGrouping.isPresent()) {
             throw new CodecPreconditionException(extension);
         }
-        Short value = matchGrouping.get().getNxmNxNsi().getNsi();
+        Short nsiValue = matchGrouping.get().getNxmNxNsi().getNsi();
+        MatchEntry matchEntry = buildMatchEntry(nsiValue, null);
+        return matchEntry;
+    }
 
-        NsiCaseValueBuilder nsiCaseValueBuilder = new NsiCaseValueBuilder();
-        nsiCaseValueBuilder.setNsiValues(new NsiValuesBuilder()
-                .setNsi(value).build());
-        return MatchUtil.createDefaultMatchEntryBuilder(
+    public static MatchEntry buildMatchEntry(Short nsi, Short mask) {
+        NsiValues nsiValues = new NsiValuesBuilder().setNsi(nsi).setMask(mask).build();
+        NsiCaseValue nsiCaseValue = new NsiCaseValueBuilder().setNsiValues(nsiValues).build();
+        return MatchUtil.createExperimenterMatchEntryBuilder(
                 org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNsi.class,
-                Nxm1Class.class, nsiCaseValueBuilder.build()).build();
+                NiciraConstants.NX_NSH_VENDOR_ID,
+                nsiCaseValue).setHasMask(mask != null).build();
     }
 
     private static ExtensionAugment<? extends Augmentation<Extension>> resolveAugmentation(NxmNxNsi value,
index 47be5017e39874561bcb865055a514e1a36a8833..eb44b15015fdbc8b7cc9fd989522d93c1054b624 100644 (file)
@@ -9,16 +9,19 @@
 package org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match;
 
 import com.google.common.base.Optional;
+import org.opendaylight.openflowjava.nx.api.NiciraConstants;
 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.nicira.convertor.CodecPreconditionException;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.OfjAugNxExpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsp.grouping.NspValues;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsp.grouping.NspValuesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.NspCaseValue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.NspCaseValueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NspCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NspCaseValueBuilder;
 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.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow;
@@ -38,11 +41,16 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni
 import org.opendaylight.yangtools.yang.binding.Augmentation;
 
 public class NspConvertor implements ConvertorToOFJava<MatchEntry>, ConvertorFromOFJava<MatchEntry, MatchPath> {
+
     @Override
     public ExtensionAugment<? extends Augmentation<Extension>> convert(MatchEntry input, MatchPath path) {
-        NspCaseValue nspCaseValue = (NspCaseValue) input.getMatchEntryValue();
+        ExperimenterIdCase experimenterIdCase = (ExperimenterIdCase) input.getMatchEntryValue();
+        OfjAugNxExpMatch ofjAugNxExpMatch = experimenterIdCase.augmentation(OfjAugNxExpMatch.class);
+        NspCaseValue nshNspCaseValue = (NspCaseValue) ofjAugNxExpMatch.getNxExpMatchEntryValue();
 
-        return resolveAugmentation(new NxmNxNspBuilder().setValue(nspCaseValue.getNspValues().getNsp()).build(), path,
+        return resolveAugmentation(
+                new NxmNxNspBuilder().setValue(nshNspCaseValue.getNspValues().getNsp()).build(),
+                path,
                 NxmNxNspKey.class);
     }
 
@@ -52,13 +60,18 @@ public class NspConvertor implements ConvertorToOFJava<MatchEntry>, ConvertorFro
         if (!matchGrouping.isPresent()) {
             throw new CodecPreconditionException(extension);
         }
-        Long value = matchGrouping.get().getNxmNxNsp().getValue();
-        NspCaseValueBuilder nspCaseValueBuilder = new NspCaseValueBuilder();
-        nspCaseValueBuilder.setNspValues(new NspValuesBuilder()
-                .setNsp(value).build());
-        return MatchUtil.createDefaultMatchEntryBuilder(
+        Long nspValue = matchGrouping.get().getNxmNxNsp().getValue();
+        MatchEntry matchEntry = buildMatchEntry(nspValue, null);
+        return matchEntry;
+    }
+
+    public static MatchEntry buildMatchEntry(Long nsp, Long mask) {
+        NspValues nspValues = new NspValuesBuilder().setNsp(nsp).setMask(mask).build();
+        NspCaseValue nspCaseValue = new NspCaseValueBuilder().setNspValues(nspValues).build();
+        return MatchUtil.createExperimenterMatchEntryBuilder(
                 org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNsp.class,
-                Nxm1Class.class, nspCaseValueBuilder.build()).build();
+                NiciraConstants.NX_NSH_VENDOR_ID,
+                nspCaseValue).setHasMask(mask != null).build();
     }
 
     private static ExtensionAugment<? extends Augmentation<Extension>> resolveAugmentation(NxmNxNsp value,
index 6d3d4a7f796f31aefa71e67fbd016cae5ce2adde..b3c714e8ad811446e0c47e7c5912b6574b9ee560 100644 (file)
@@ -320,6 +320,9 @@ module openflowplugin-extension-nicira-match {
             leaf value {
                 type uint32;
             }
+            leaf mask {
+                type uint32;
+            }
         }
     }
     grouping nxm-nx-nshc-2-grouping {
@@ -327,6 +330,9 @@ module openflowplugin-extension-nicira-match {
             leaf value {
                 type uint32;
             }
+            leaf mask {
+                type uint32;
+            }
         }
     }
     grouping nxm-nx-nshc-3-grouping {
@@ -334,6 +340,9 @@ module openflowplugin-extension-nicira-match {
             leaf value {
                 type uint32;
             }
+            leaf mask {
+                type uint32;
+            }
         }
     }
     grouping nxm-nx-nshc-4-grouping {
@@ -341,6 +350,9 @@ module openflowplugin-extension-nicira-match {
             leaf value {
                 type uint32;
             }
+            leaf mask {
+                type uint32;
+            }
         }
     }
     grouping nxm-nx-ct-state-grouping {
index de818b9a13f33ab680d66d3db3c803e50bcdde26..dccdc761f9f3aa02f3567961ae496156834fbe3d 100644 (file)
@@ -62,7 +62,11 @@ public class RegLoad2ConvertorTest {
         return Arrays.asList(new Object[][] {
                 // specified values do not fit in the bit range
                 {1, 5, 0xFF, null, null, IllegalArgumentException.class},
-                {3, 5, 0x08, null, null, IllegalArgumentException.class}
+                {3, 5, 0x08, null, null, IllegalArgumentException.class},
+                // out of range value and mask
+                {0, 16, 0x1FFFF, null, null, IllegalArgumentException.class},
+                // out of range mask
+                {0, 16, 0x1, null, null, IllegalArgumentException.class}
         });
     }
 
diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshMdtypeConvertorTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshMdtypeConvertorTest.java
new file mode 100644 (file)
index 0000000..bfc2f5c
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2018 SUSE LINUX GmbH.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the 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.nicira.convertor.match;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+
+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.openflowjava.nx.api.NiciraConstants;
+import org.opendaylight.openflowplugin.extension.api.ExtensionAugment;
+import org.opendaylight.openflowplugin.extension.api.path.MatchPath;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.OfjAugNxExpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshMdtypeCaseValue;
+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.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifPacketIn;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifSwitchFlowRemoved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchRpcGetFlowStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxNshMdtypeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsh.mdtype.grouping.NxmNxNshMdtype;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsh.mdtype.grouping.NxmNxNshMdtypeBuilder;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+
+@RunWith(MockitoJUnitRunner.class)
+public class NshMdtypeConvertorTest {
+    @Mock
+    private Extension extension;
+
+    private NshMdtypeConvertor convertor;
+
+    private static final Short MDTYPE_VALUE = (short) 0x7B;
+
+    @Before
+    public void setUp() throws Exception {
+        NxmNxNshMdtype nxmNxNshMdtype = new NxmNxNshMdtypeBuilder()
+                .setValue(MDTYPE_VALUE)
+                .build();
+        NxAugMatchNodesNodeTableFlow nxAugMatchNotifUpdateFlowStats = new NxAugMatchNodesNodeTableFlowBuilder()
+                .setNxmNxNshMdtype(nxmNxNshMdtype)
+                .build();
+        when(extension.augmentation(Matchers.<Class<Augmentation<Extension>>>any()))
+                .thenReturn(nxAugMatchNotifUpdateFlowStats);
+
+        convertor = new NshMdtypeConvertor();
+    }
+
+    @Test
+    public void testConvertToOFJava() {
+
+        final MatchEntry converted = convertor.convert(extension);
+
+        ExperimenterIdCase experimenterIdCase = (ExperimenterIdCase) converted.getMatchEntryValue();
+        OfjAugNxExpMatch ofjAugNxExpMatch = experimenterIdCase.augmentation(OfjAugNxExpMatch.class);
+        NshMdtypeCaseValue nshMdtypeCaseValue = (NshMdtypeCaseValue) ofjAugNxExpMatch.getNxExpMatchEntryValue();
+        assertEquals(NiciraConstants.NX_NSH_VENDOR_ID,
+                experimenterIdCase.getExperimenter().getExperimenter().getValue());
+        assertEquals(MDTYPE_VALUE, nshMdtypeCaseValue.getNshMdtypeValues().getValue());
+    }
+
+    @Test
+    public void testConvertToOFSal() {
+        MatchEntry matchEntry = NshMdtypeConvertor.buildMatchEntry(MDTYPE_VALUE, null);
+
+        final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment = convertor.convert(matchEntry,
+                MatchPath.PACKET_RECEIVED_MATCH);
+        assertEquals(MDTYPE_VALUE, ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject())
+                .getNxmNxNshMdtype().getValue());
+        assertEquals(extensionAugment.getKey(), NxmNxNshMdtypeKey.class);
+
+        final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment1 = convertor.convert(matchEntry,
+                MatchPath.SWITCH_FLOW_REMOVED_MATCH);
+        assertEquals(MDTYPE_VALUE, ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject())
+                .getNxmNxNshMdtype().getValue());
+        assertEquals(extensionAugment.getKey(), NxmNxNshMdtypeKey.class);
+
+        final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment2 = convertor.convert(matchEntry,
+                MatchPath.FLOWS_STATISTICS_UPDATE_MATCH);
+        assertEquals(MDTYPE_VALUE, ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject())
+                .getNxmNxNshMdtype().getValue());
+        assertEquals(extensionAugment.getKey(), NxmNxNshMdtypeKey.class);
+
+        final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment3 = convertor.convert(matchEntry,
+                MatchPath.FLOWS_STATISTICS_RPC_MATCH);
+        assertEquals(MDTYPE_VALUE, ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject())
+                .getNxmNxNshMdtype().getValue());
+        assertEquals(extensionAugment.getKey(), NxmNxNshMdtypeKey.class);
+    }
+}
\ No newline at end of file
diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshNpConvertorTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshNpConvertorTest.java
new file mode 100644 (file)
index 0000000..17f78a9
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2018 SUSE LINUX GmbH.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the 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.nicira.convertor.match;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+
+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.openflowjava.nx.api.NiciraConstants;
+import org.opendaylight.openflowplugin.extension.api.ExtensionAugment;
+import org.opendaylight.openflowplugin.extension.api.path.MatchPath;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.OfjAugNxExpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshNpCaseValue;
+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.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifPacketIn;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifSwitchFlowRemoved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchRpcGetFlowStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxNshNpKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsh.np.grouping.NxmNxNshNp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsh.np.grouping.NxmNxNshNpBuilder;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+
+@RunWith(MockitoJUnitRunner.class)
+public class NshNpConvertorTest {
+    @Mock
+    private Extension extension;
+
+    private NshNpConvertor convertor;
+
+    private static final Short NP_VALUE = (short) 0x7B;
+
+    @Before
+    public void setUp() throws Exception {
+        NxmNxNshNp nxmNxNshNp = new NxmNxNshNpBuilder()
+                .setValue(NP_VALUE)
+                .build();
+        NxAugMatchNodesNodeTableFlow nxAugMatchNotifUpdateFlowStats = new NxAugMatchNodesNodeTableFlowBuilder()
+                .setNxmNxNshNp(nxmNxNshNp)
+                .build();
+        when(extension.augmentation(Matchers.<Class<Augmentation<Extension>>>any()))
+                .thenReturn(nxAugMatchNotifUpdateFlowStats);
+
+        convertor = new NshNpConvertor();
+    }
+
+    @Test
+    public void testConvertToOFJava() {
+
+        final MatchEntry converted = convertor.convert(extension);
+
+        ExperimenterIdCase experimenterIdCase = (ExperimenterIdCase) converted.getMatchEntryValue();
+        OfjAugNxExpMatch ofjAugNxExpMatch = experimenterIdCase.augmentation(OfjAugNxExpMatch.class);
+        NshNpCaseValue nshNpCaseValue = (NshNpCaseValue) ofjAugNxExpMatch.getNxExpMatchEntryValue();
+        assertEquals(NiciraConstants.NX_NSH_VENDOR_ID,
+                experimenterIdCase.getExperimenter().getExperimenter().getValue());
+        assertEquals(NP_VALUE, nshNpCaseValue.getNshNpValues().getValue());
+    }
+
+    @Test
+    public void testConvertToOFSal() {
+        MatchEntry matchEntry = NshNpConvertor.buildMatchEntry(NP_VALUE, null);
+
+        final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment = convertor.convert(matchEntry,
+                MatchPath.PACKET_RECEIVED_MATCH);
+        assertEquals(NP_VALUE, ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject())
+                .getNxmNxNshNp().getValue());
+        assertEquals(extensionAugment.getKey(), NxmNxNshNpKey.class);
+
+        final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment1 = convertor.convert(matchEntry,
+                MatchPath.SWITCH_FLOW_REMOVED_MATCH);
+        assertEquals(NP_VALUE, ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject())
+                .getNxmNxNshNp().getValue());
+        assertEquals(extensionAugment.getKey(), NxmNxNshNpKey.class);
+
+        final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment2 = convertor.convert(matchEntry,
+                MatchPath.FLOWS_STATISTICS_UPDATE_MATCH);
+        assertEquals(NP_VALUE, ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject())
+                .getNxmNxNshNp().getValue());
+        assertEquals(extensionAugment.getKey(), NxmNxNshNpKey.class);
+
+        final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment3 = convertor.convert(matchEntry,
+                MatchPath.FLOWS_STATISTICS_RPC_MATCH);
+        assertEquals(NP_VALUE, ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject())
+                .getNxmNxNshNp().getValue());
+        assertEquals(extensionAugment.getKey(), NxmNxNshNpKey.class);
+    }
+}
\ No newline at end of file
index 9ad530879d8e6ff53ca3b787fe75d305d6b93c56..2cff7c0984e0ee1f167db1465ed82d5094d721f1 100644 (file)
@@ -17,12 +17,13 @@ import org.junit.runner.RunWith;
 import org.mockito.Matchers;
 import org.mockito.Mock;
 import org.mockito.runners.MockitoJUnitRunner;
+import org.opendaylight.openflowjava.nx.api.NiciraConstants;
 import org.opendaylight.openflowplugin.extension.api.ExtensionAugment;
 import org.opendaylight.openflowplugin.extension.api.path.MatchPath;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nshc._1.grouping.Nshc1ValuesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc1CaseValue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc1CaseValueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.OfjAugNxExpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshcCaseValue;
 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.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlowBuilder;
@@ -30,6 +31,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifSwitchFlowRemoved;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchRpcGetFlowStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxNshc1Key;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._1.grouping.NxmNxNshc1;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._1.grouping.NxmNxNshc1Builder;
 import org.opendaylight.yangtools.yang.binding.Augmentation;
 
@@ -38,68 +40,74 @@ import org.opendaylight.yangtools.yang.binding.Augmentation;
  */
 @RunWith(MockitoJUnitRunner.class)
 public class Nshc1ConvertorTest {
-
     @Mock
     private Extension extension;
-    @Mock
-    private MatchEntry matchEntry;
 
     private Nshc1Convertor nshc1Convertor;
 
+    private static final Long NSHC1_VALUE = 0xFFFFFFFFL;
+    private static final Long MASK_VALUE = 0xFFFFFFFFL;
+
     @Before
     public void setUp() throws Exception {
-        final NxmNxNshc1Builder nxmNxNshc1Builder = new NxmNxNshc1Builder()
-                .setValue(1L);
-        final NxAugMatchNodesNodeTableFlowBuilder nxAugMatchNotifUpdateFlowStatsBuilder =
-                new NxAugMatchNodesNodeTableFlowBuilder();
-        nxAugMatchNotifUpdateFlowStatsBuilder.setNxmNxNshc1(nxmNxNshc1Builder.build());
-
-        final Augmentation<Extension> extensionAugmentation = nxAugMatchNotifUpdateFlowStatsBuilder.build();
+        NxmNxNshc1 nxmNxNshc1 = new NxmNxNshc1Builder().setValue(NSHC1_VALUE).setMask(MASK_VALUE).build();
+        NxAugMatchNodesNodeTableFlow nxAugMatchNotifUpdateFlowStats = new NxAugMatchNodesNodeTableFlowBuilder()
+                .setNxmNxNshc1(nxmNxNshc1)
+                .build();
         when(extension.augmentation(Matchers.<Class<Augmentation<Extension>>>any()))
-            .thenReturn(extensionAugmentation);
+                .thenReturn(nxAugMatchNotifUpdateFlowStats);
 
         nshc1Convertor = new Nshc1Convertor();
     }
 
     @Test
-    public void testConvert() throws Exception {
+    public void testConvertToOFJava() {
         final MatchEntry converted = nshc1Convertor.convert(extension);
-        Assert.assertEquals(1, ((Nshc1CaseValue)converted.getMatchEntryValue()).getNshc1Values().getNshc().intValue());
+        ExperimenterIdCase experimenterIdCase = (ExperimenterIdCase) converted.getMatchEntryValue();
+        OfjAugNxExpMatch ofjAugNxExpMatch = experimenterIdCase.augmentation(OfjAugNxExpMatch.class);
+        NshcCaseValue nshcCaseValue = (NshcCaseValue) ofjAugNxExpMatch.getNxExpMatchEntryValue();
+        Assert.assertEquals(NiciraConstants.NX_NSH_VENDOR_ID,
+                experimenterIdCase.getExperimenter().getExperimenter().getValue());
+        Assert.assertEquals(NSHC1_VALUE, nshcCaseValue.getNshc());
+        Assert.assertEquals(MASK_VALUE, nshcCaseValue.getMask());
     }
 
     @Test
-    public void testConvert1() throws Exception {
-        final Nshc1ValuesBuilder nshc1ValuesBuilder = new Nshc1ValuesBuilder()
-                .setNshc(Long.valueOf(1));
-        final Nshc1CaseValueBuilder nshc1CaseValueBuilder = new Nshc1CaseValueBuilder()
-                .setNshc1Values(nshc1ValuesBuilder.build());
-
-        final Nshc1CaseValue nshc1CaseValue = nshc1CaseValueBuilder.build();
-
-        when(matchEntry.getMatchEntryValue()).thenReturn(nshc1CaseValue);
+    public void testConvertToOFSal() {
+        MatchEntry matchEntry = Nshc1Convertor.buildMatchEntry(NSHC1_VALUE, MASK_VALUE);
 
         final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment = nshc1Convertor.convert(matchEntry,
                 MatchPath.PACKET_RECEIVED_MATCH);
-        Assert.assertEquals(1, ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject()).getNxmNxNshc1()
-                .getValue().intValue());
+        Assert.assertEquals(NSHC1_VALUE,
+                ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject()).getNxmNxNshc1().getValue());
+        Assert.assertEquals(MASK_VALUE,
+                ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject()).getNxmNxNshc1().getMask());
         Assert.assertEquals(extensionAugment.getKey(), NxmNxNshc1Key.class);
 
         final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment1 = nshc1Convertor.convert(matchEntry,
                 MatchPath.SWITCH_FLOW_REMOVED_MATCH);
-        Assert.assertEquals(1, ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject())
-                .getNxmNxNshc1().getValue().intValue());
+        Assert.assertEquals(NSHC1_VALUE,
+                ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject())
+                        .getNxmNxNshc1().getValue());
+        Assert.assertEquals(MASK_VALUE,
+                ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject())
+                        .getNxmNxNshc1().getMask());
         Assert.assertEquals(extensionAugment.getKey(), NxmNxNshc1Key.class);
 
         final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment2 = nshc1Convertor.convert(matchEntry,
                 MatchPath.FLOWS_STATISTICS_UPDATE_MATCH);
-        Assert.assertEquals(1, ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject())
-                .getNxmNxNshc1().getValue().intValue());
+        Assert.assertEquals(NSHC1_VALUE,
+                ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject()).getNxmNxNshc1().getValue());
+        Assert.assertEquals(MASK_VALUE,
+                ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject()).getNxmNxNshc1().getMask());
         Assert.assertEquals(extensionAugment.getKey(), NxmNxNshc1Key.class);
 
         final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment3 = nshc1Convertor.convert(matchEntry,
                 MatchPath.FLOWS_STATISTICS_RPC_MATCH);
-        Assert.assertEquals(1, ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject()).getNxmNxNshc1()
-                .getValue().intValue());
+        Assert.assertEquals(NSHC1_VALUE,
+                ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject()).getNxmNxNshc1().getValue());
+        Assert.assertEquals(MASK_VALUE,
+                ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject()).getNxmNxNshc1().getMask());
         Assert.assertEquals(extensionAugment.getKey(), NxmNxNshc1Key.class);
     }
 }
index f6ecfac893c9ad9fd6e89ebb2b35fae56742c43a..513c36c3429ffb0ba4fd3b4401c21ee649623d1e 100644 (file)
@@ -17,12 +17,13 @@ import org.junit.runner.RunWith;
 import org.mockito.Matchers;
 import org.mockito.Mock;
 import org.mockito.runners.MockitoJUnitRunner;
+import org.opendaylight.openflowjava.nx.api.NiciraConstants;
 import org.opendaylight.openflowplugin.extension.api.ExtensionAugment;
 import org.opendaylight.openflowplugin.extension.api.path.MatchPath;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nshc._2.grouping.Nshc2ValuesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc2CaseValue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc2CaseValueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.OfjAugNxExpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshcCaseValue;
 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.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlowBuilder;
@@ -30,6 +31,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifSwitchFlowRemoved;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchRpcGetFlowStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxNshc2Key;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._2.grouping.NxmNxNshc2;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._2.grouping.NxmNxNshc2Builder;
 import org.opendaylight.yangtools.yang.binding.Augmentation;
 
@@ -40,65 +42,72 @@ import org.opendaylight.yangtools.yang.binding.Augmentation;
 public class Nshc2ConvertorTest {
     @Mock
     private Extension extension;
-    @Mock
-    private MatchEntry matchEntry;
 
     private Nshc2Convertor nshc2Convertor;
 
+    private static final Long NSHC2_VALUE = 0xFFFFFFFFL;
+    private static final Long MASK_VALUE = 0xFFFFFFFFL;
+
     @Before
     public void setUp() throws Exception {
-        final NxmNxNshc2Builder nxmNxNshc2Builder = new NxmNxNshc2Builder()
-                .setValue(1L);
-        final NxAugMatchNodesNodeTableFlowBuilder nxAugMatchNotifUpdateFlowStatsBuilder =
-                new NxAugMatchNodesNodeTableFlowBuilder();
-        nxAugMatchNotifUpdateFlowStatsBuilder.setNxmNxNshc2(nxmNxNshc2Builder.build());
-
-        final Augmentation<Extension> extensionAugmentation = nxAugMatchNotifUpdateFlowStatsBuilder.build();
+        NxmNxNshc2 nxmNxNshc2 = new NxmNxNshc2Builder().setValue(NSHC2_VALUE).setMask(MASK_VALUE).build();
+        NxAugMatchNodesNodeTableFlow nxAugMatchNotifUpdateFlowStats = new NxAugMatchNodesNodeTableFlowBuilder()
+                .setNxmNxNshc2(nxmNxNshc2)
+                .build();
         when(extension.augmentation(Matchers.<Class<Augmentation<Extension>>>any()))
-            .thenReturn(extensionAugmentation);
+                .thenReturn(nxAugMatchNotifUpdateFlowStats);
 
         nshc2Convertor = new Nshc2Convertor();
     }
 
     @Test
-    public void testConvert() throws Exception {
+    public void testConvertToOFJava() {
         final MatchEntry converted = nshc2Convertor.convert(extension);
-        Assert.assertEquals(1, ((Nshc2CaseValue)converted.getMatchEntryValue()).getNshc2Values().getNshc().intValue());
+        ExperimenterIdCase experimenterIdCase = (ExperimenterIdCase) converted.getMatchEntryValue();
+        OfjAugNxExpMatch ofjAugNxExpMatch = experimenterIdCase.augmentation(OfjAugNxExpMatch.class);
+        NshcCaseValue nshcCaseValue = (NshcCaseValue) ofjAugNxExpMatch.getNxExpMatchEntryValue();
+        Assert.assertEquals(NiciraConstants.NX_NSH_VENDOR_ID,
+                experimenterIdCase.getExperimenter().getExperimenter().getValue());
+        Assert.assertEquals(NSHC2_VALUE, nshcCaseValue.getNshc());
+        Assert.assertEquals(MASK_VALUE, nshcCaseValue.getMask());
     }
 
     @Test
-    public void testConvert1() throws Exception {
-        final Nshc2ValuesBuilder nshc2ValuesBuilder = new Nshc2ValuesBuilder()
-                .setNshc(Long.valueOf(1));
-        final Nshc2CaseValueBuilder nshc2CaseValueBuilder = new Nshc2CaseValueBuilder()
-                .setNshc2Values(nshc2ValuesBuilder.build());
-
-        final Nshc2CaseValue nshc2CaseValue = nshc2CaseValueBuilder.build();
-
-        when(matchEntry.getMatchEntryValue()).thenReturn(nshc2CaseValue);
+    public void testConvertToOFSal() {
+        MatchEntry matchEntry = Nshc2Convertor.buildMatchEntry(NSHC2_VALUE, MASK_VALUE);
 
         final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment = nshc2Convertor.convert(matchEntry,
                 MatchPath.PACKET_RECEIVED_MATCH);
-        Assert.assertEquals(1, ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject()).getNxmNxNshc2()
-                .getValue().intValue());
+        Assert.assertEquals(NSHC2_VALUE,
+                ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject()).getNxmNxNshc2().getValue());
+        Assert.assertEquals(MASK_VALUE,
+                ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject()).getNxmNxNshc2().getMask());
         Assert.assertEquals(extensionAugment.getKey(), NxmNxNshc2Key.class);
 
         final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment1 = nshc2Convertor.convert(matchEntry,
                 MatchPath.SWITCH_FLOW_REMOVED_MATCH);
-        Assert.assertEquals(1, ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject())
-                .getNxmNxNshc2().getValue().intValue());
+        Assert.assertEquals(NSHC2_VALUE,
+                ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject())
+                        .getNxmNxNshc2().getValue());
+        Assert.assertEquals(MASK_VALUE,
+                ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject())
+                        .getNxmNxNshc2().getMask());
         Assert.assertEquals(extensionAugment.getKey(), NxmNxNshc2Key.class);
 
         final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment2 = nshc2Convertor.convert(matchEntry,
                 MatchPath.FLOWS_STATISTICS_UPDATE_MATCH);
-        Assert.assertEquals(1, ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject())
-                .getNxmNxNshc2().getValue().intValue());
+        Assert.assertEquals(NSHC2_VALUE,
+                ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject()).getNxmNxNshc2().getValue());
+        Assert.assertEquals(MASK_VALUE,
+                ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject()).getNxmNxNshc2().getMask());
         Assert.assertEquals(extensionAugment.getKey(), NxmNxNshc2Key.class);
 
         final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment3 = nshc2Convertor.convert(matchEntry,
                 MatchPath.FLOWS_STATISTICS_RPC_MATCH);
-        Assert.assertEquals(1, ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject()).getNxmNxNshc2()
-                .getValue().intValue());
+        Assert.assertEquals(NSHC2_VALUE,
+                ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject()).getNxmNxNshc2().getValue());
+        Assert.assertEquals(MASK_VALUE,
+                ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject()).getNxmNxNshc2().getMask());
         Assert.assertEquals(extensionAugment.getKey(), NxmNxNshc2Key.class);
     }
 }
index 1a42de53b7bfcd124b01de41835fb8eaf11dceb7..84de5bc83651a60cdbbb93c517b17934a766e690 100644 (file)
@@ -17,12 +17,13 @@ import org.junit.runner.RunWith;
 import org.mockito.Matchers;
 import org.mockito.Mock;
 import org.mockito.runners.MockitoJUnitRunner;
+import org.opendaylight.openflowjava.nx.api.NiciraConstants;
 import org.opendaylight.openflowplugin.extension.api.ExtensionAugment;
 import org.opendaylight.openflowplugin.extension.api.path.MatchPath;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nshc._3.grouping.Nshc3ValuesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc3CaseValue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc3CaseValueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.OfjAugNxExpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshcCaseValue;
 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.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlowBuilder;
@@ -30,6 +31,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifSwitchFlowRemoved;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchRpcGetFlowStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxNshc3Key;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._3.grouping.NxmNxNshc3;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._3.grouping.NxmNxNshc3Builder;
 import org.opendaylight.yangtools.yang.binding.Augmentation;
 
@@ -38,68 +40,74 @@ import org.opendaylight.yangtools.yang.binding.Augmentation;
  */
 @RunWith(MockitoJUnitRunner.class)
 public class Nshc3ConvertorTest {
-
     @Mock
     private Extension extension;
-    @Mock
-    private MatchEntry matchEntry;
 
     private Nshc3Convertor nshc3Convertor;
 
+    private static final Long NSHC3_VALUE = 0xFFFFFFFFL;
+    private static final Long MASK_VALUE = 0xFFFFFFFFL;
+
     @Before
     public void setUp() throws Exception {
-        final NxmNxNshc3Builder nxmNxNshc3Builder = new NxmNxNshc3Builder()
-                .setValue(1L);
-        final NxAugMatchNodesNodeTableFlowBuilder nxAugMatchNotifUpdateFlowStatsBuilder =
-                new NxAugMatchNodesNodeTableFlowBuilder();
-        nxAugMatchNotifUpdateFlowStatsBuilder.setNxmNxNshc3(nxmNxNshc3Builder.build());
-
-        final Augmentation<Extension> extensionAugmentation = nxAugMatchNotifUpdateFlowStatsBuilder.build();
+        NxmNxNshc3 nxmNxNshc3 = new NxmNxNshc3Builder().setValue(NSHC3_VALUE).setMask(MASK_VALUE).build();
+        NxAugMatchNodesNodeTableFlow nxAugMatchNotifUpdateFlowStats = new NxAugMatchNodesNodeTableFlowBuilder()
+                .setNxmNxNshc3(nxmNxNshc3)
+                .build();
         when(extension.augmentation(Matchers.<Class<Augmentation<Extension>>>any()))
-            .thenReturn(extensionAugmentation);
+                .thenReturn(nxAugMatchNotifUpdateFlowStats);
 
         nshc3Convertor = new Nshc3Convertor();
     }
 
     @Test
-    public void testConvert() throws Exception {
+    public void testConvertToOFJava() {
         final MatchEntry converted = nshc3Convertor.convert(extension);
-        Assert.assertEquals(1, ((Nshc3CaseValue)converted.getMatchEntryValue()).getNshc3Values().getNshc().intValue());
+        ExperimenterIdCase experimenterIdCase = (ExperimenterIdCase) converted.getMatchEntryValue();
+        OfjAugNxExpMatch ofjAugNxExpMatch = experimenterIdCase.augmentation(OfjAugNxExpMatch.class);
+        NshcCaseValue nshcCaseValue = (NshcCaseValue) ofjAugNxExpMatch.getNxExpMatchEntryValue();
+        Assert.assertEquals(NiciraConstants.NX_NSH_VENDOR_ID,
+                experimenterIdCase.getExperimenter().getExperimenter().getValue());
+        Assert.assertEquals(NSHC3_VALUE, nshcCaseValue.getNshc());
+        Assert.assertEquals(MASK_VALUE, nshcCaseValue.getMask());
     }
 
     @Test
-    public void testConvert1() throws Exception {
-        final Nshc3ValuesBuilder nshc3ValuesBuilder = new Nshc3ValuesBuilder()
-                .setNshc(Long.valueOf(1));
-        final Nshc3CaseValueBuilder nshc3CaseValueBuilder = new Nshc3CaseValueBuilder()
-                .setNshc3Values(nshc3ValuesBuilder.build());
-
-        final Nshc3CaseValue nshc3CaseValue = nshc3CaseValueBuilder.build();
-
-        when(matchEntry.getMatchEntryValue()).thenReturn(nshc3CaseValue);
+    public void testConvertToOFSal() {
+        MatchEntry matchEntry = Nshc3Convertor.buildMatchEntry(NSHC3_VALUE, MASK_VALUE);
 
         final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment = nshc3Convertor.convert(matchEntry,
                 MatchPath.PACKET_RECEIVED_MATCH);
-        Assert.assertEquals(1, ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject()).getNxmNxNshc3()
-                .getValue().intValue());
+        Assert.assertEquals(NSHC3_VALUE,
+                ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject()).getNxmNxNshc3().getValue());
+        Assert.assertEquals(MASK_VALUE,
+                ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject()).getNxmNxNshc3().getMask());
         Assert.assertEquals(extensionAugment.getKey(), NxmNxNshc3Key.class);
 
         final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment1 = nshc3Convertor.convert(matchEntry,
                 MatchPath.SWITCH_FLOW_REMOVED_MATCH);
-        Assert.assertEquals(1, ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject())
-                .getNxmNxNshc3().getValue().intValue());
+        Assert.assertEquals(NSHC3_VALUE,
+                ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject())
+                        .getNxmNxNshc3().getValue());
+        Assert.assertEquals(MASK_VALUE,
+                ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject())
+                        .getNxmNxNshc3().getMask());
         Assert.assertEquals(extensionAugment.getKey(), NxmNxNshc3Key.class);
 
         final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment2 = nshc3Convertor.convert(matchEntry,
                 MatchPath.FLOWS_STATISTICS_UPDATE_MATCH);
-        Assert.assertEquals(1, ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject())
-                .getNxmNxNshc3().getValue().intValue());
+        Assert.assertEquals(NSHC3_VALUE,
+                ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject()).getNxmNxNshc3().getValue());
+        Assert.assertEquals(MASK_VALUE,
+                ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject()).getNxmNxNshc3().getMask());
         Assert.assertEquals(extensionAugment.getKey(), NxmNxNshc3Key.class);
 
         final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment3 = nshc3Convertor.convert(matchEntry,
                 MatchPath.FLOWS_STATISTICS_RPC_MATCH);
-        Assert.assertEquals(1, ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject()).getNxmNxNshc3()
-                .getValue().intValue());
+        Assert.assertEquals(NSHC3_VALUE,
+                ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject()).getNxmNxNshc3().getValue());
+        Assert.assertEquals(MASK_VALUE,
+                ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject()).getNxmNxNshc3().getMask());
         Assert.assertEquals(extensionAugment.getKey(), NxmNxNshc3Key.class);
     }
 }
index e0a7c4c918bc34d5012e83bb1aa015e46ca77884..aa369ba4db955aa83a777707b72a62e645e808e5 100644 (file)
@@ -17,12 +17,13 @@ import org.junit.runner.RunWith;
 import org.mockito.Matchers;
 import org.mockito.Mock;
 import org.mockito.runners.MockitoJUnitRunner;
+import org.opendaylight.openflowjava.nx.api.NiciraConstants;
 import org.opendaylight.openflowplugin.extension.api.ExtensionAugment;
 import org.opendaylight.openflowplugin.extension.api.path.MatchPath;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nshc._4.grouping.Nshc4ValuesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc4CaseValue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc4CaseValueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.OfjAugNxExpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshcCaseValue;
 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.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlowBuilder;
@@ -30,6 +31,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifSwitchFlowRemoved;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchRpcGetFlowStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxNshc4Key;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._4.grouping.NxmNxNshc4;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._4.grouping.NxmNxNshc4Builder;
 import org.opendaylight.yangtools.yang.binding.Augmentation;
 
@@ -40,65 +42,72 @@ import org.opendaylight.yangtools.yang.binding.Augmentation;
 public class Nshc4ConvertorTest {
     @Mock
     private Extension extension;
-    @Mock
-    private MatchEntry matchEntry;
 
     private Nshc4Convertor nshc4Convertor;
 
+    private static final Long NSHC4_VALUE = 0xFFFFFFFFL;
+    private static final Long MASK_VALUE = 0xFFFFFFFFL;
+
     @Before
     public void setUp() throws Exception {
-        final NxmNxNshc4Builder nxmNxNshc4Builder = new NxmNxNshc4Builder()
-                .setValue(1L);
-        final NxAugMatchNodesNodeTableFlowBuilder nxAugMatchNotifUpdateFlowStatsBuilder =
-                new NxAugMatchNodesNodeTableFlowBuilder();
-        nxAugMatchNotifUpdateFlowStatsBuilder.setNxmNxNshc4(nxmNxNshc4Builder.build());
-
-        final Augmentation<Extension> extensionAugmentation = nxAugMatchNotifUpdateFlowStatsBuilder.build();
+        NxmNxNshc4 nxmNxNshc4 = new NxmNxNshc4Builder().setValue(NSHC4_VALUE).setMask(MASK_VALUE).build();
+        NxAugMatchNodesNodeTableFlow nxAugMatchNotifUpdateFlowStats = new NxAugMatchNodesNodeTableFlowBuilder()
+                .setNxmNxNshc4(nxmNxNshc4)
+                .build();
         when(extension.augmentation(Matchers.<Class<Augmentation<Extension>>>any()))
-            .thenReturn(extensionAugmentation);
+                .thenReturn(nxAugMatchNotifUpdateFlowStats);
 
         nshc4Convertor = new Nshc4Convertor();
     }
 
     @Test
-    public void testConvert() throws Exception {
+    public void testConvertToOFJava() {
         final MatchEntry converted = nshc4Convertor.convert(extension);
-        Assert.assertEquals(1, ((Nshc4CaseValue)converted.getMatchEntryValue()).getNshc4Values().getNshc().intValue());
+        ExperimenterIdCase experimenterIdCase = (ExperimenterIdCase) converted.getMatchEntryValue();
+        OfjAugNxExpMatch ofjAugNxExpMatch = experimenterIdCase.augmentation(OfjAugNxExpMatch.class);
+        NshcCaseValue nshcCaseValue = (NshcCaseValue) ofjAugNxExpMatch.getNxExpMatchEntryValue();
+        Assert.assertEquals(NiciraConstants.NX_NSH_VENDOR_ID,
+                experimenterIdCase.getExperimenter().getExperimenter().getValue());
+        Assert.assertEquals(NSHC4_VALUE, nshcCaseValue.getNshc());
+        Assert.assertEquals(MASK_VALUE, nshcCaseValue.getMask());
     }
 
     @Test
-    public void testConvert1() throws Exception {
-        final Nshc4ValuesBuilder nshc4ValuesBuilder = new Nshc4ValuesBuilder()
-                .setNshc(Long.valueOf(1));
-        final Nshc4CaseValueBuilder nshc4CaseValueBuilder = new Nshc4CaseValueBuilder()
-                .setNshc4Values(nshc4ValuesBuilder.build());
-
-        final Nshc4CaseValue nshc4CaseValue = nshc4CaseValueBuilder.build();
-
-        when(matchEntry.getMatchEntryValue()).thenReturn(nshc4CaseValue);
+    public void testConvertToOFSal() {
+        MatchEntry matchEntry = Nshc4Convertor.buildMatchEntry(NSHC4_VALUE, MASK_VALUE);
 
         final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment = nshc4Convertor.convert(matchEntry,
                 MatchPath.PACKET_RECEIVED_MATCH);
-        Assert.assertEquals(1, ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject()).getNxmNxNshc4()
-                .getValue().intValue());
+        Assert.assertEquals(NSHC4_VALUE,
+                ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject()).getNxmNxNshc4().getValue());
+        Assert.assertEquals(MASK_VALUE,
+                ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject()).getNxmNxNshc4().getMask());
         Assert.assertEquals(extensionAugment.getKey(), NxmNxNshc4Key.class);
 
         final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment1 = nshc4Convertor.convert(matchEntry,
                 MatchPath.SWITCH_FLOW_REMOVED_MATCH);
-        Assert.assertEquals(1, ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject())
-                .getNxmNxNshc4().getValue().intValue());
+        Assert.assertEquals(NSHC4_VALUE,
+                ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject())
+                        .getNxmNxNshc4().getValue());
+        Assert.assertEquals(MASK_VALUE,
+                ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject())
+                        .getNxmNxNshc4().getMask());
         Assert.assertEquals(extensionAugment.getKey(), NxmNxNshc4Key.class);
 
         final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment2 = nshc4Convertor.convert(matchEntry,
                 MatchPath.FLOWS_STATISTICS_UPDATE_MATCH);
-        Assert.assertEquals(1, ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject())
-                .getNxmNxNshc4().getValue().intValue());
+        Assert.assertEquals(NSHC4_VALUE,
+                ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject()).getNxmNxNshc4().getValue());
+        Assert.assertEquals(MASK_VALUE,
+                ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject()).getNxmNxNshc4().getMask());
         Assert.assertEquals(extensionAugment.getKey(), NxmNxNshc4Key.class);
 
         final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment3 = nshc4Convertor.convert(matchEntry,
                 MatchPath.FLOWS_STATISTICS_RPC_MATCH);
-        Assert.assertEquals(1, ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject()).getNxmNxNshc4()
-                .getValue().intValue());
+        Assert.assertEquals(NSHC4_VALUE,
+                ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject()).getNxmNxNshc4().getValue());
+        Assert.assertEquals(MASK_VALUE,
+                ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject()).getNxmNxNshc4().getMask());
         Assert.assertEquals(extensionAugment.getKey(), NxmNxNshc4Key.class);
     }
 }
index 266345731c6a21118d72555314810380cc953d0e..eb5bdac235f14c3474ab229fd04bd7eb9e3c9519 100644 (file)
@@ -17,12 +17,13 @@ import org.junit.runner.RunWith;
 import org.mockito.Matchers;
 import org.mockito.Mock;
 import org.mockito.runners.MockitoJUnitRunner;
+import org.opendaylight.openflowjava.nx.api.NiciraConstants;
 import org.opendaylight.openflowplugin.extension.api.ExtensionAugment;
 import org.opendaylight.openflowplugin.extension.api.path.MatchPath;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsi.grouping.NsiValuesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.NsiCaseValue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.NsiCaseValueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.OfjAugNxExpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NsiCaseValue;
 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.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlowBuilder;
@@ -30,6 +31,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifSwitchFlowRemoved;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchRpcGetFlowStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxNsiKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsi.grouping.NxmNxNsi;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsi.grouping.NxmNxNsiBuilder;
 import org.opendaylight.yangtools.yang.binding.Augmentation;
 
@@ -40,65 +42,61 @@ import org.opendaylight.yangtools.yang.binding.Augmentation;
 public class NsiConvertorTest {
     @Mock
     private Extension extension;
-    @Mock
-    private MatchEntry matchEntry;
 
     private NsiConvertor nsiConvertor;
 
+    private static final Short NSI_VALUE = (short) 255;
+
     @Before
     public void setUp() throws Exception {
-        final NxmNxNsiBuilder nxmNxNsiBuilder = new NxmNxNsiBuilder()
-                .setNsi((short)1);
-        final NxAugMatchNodesNodeTableFlowBuilder nxAugMatchNotifUpdateFlowStatsBuilder =
-                new NxAugMatchNodesNodeTableFlowBuilder();
-        nxAugMatchNotifUpdateFlowStatsBuilder.setNxmNxNsi(nxmNxNsiBuilder.build());
-
-        final Augmentation<Extension> extensionAugmentation = nxAugMatchNotifUpdateFlowStatsBuilder.build();
+        NxmNxNsi nxmNxNsi = new NxmNxNsiBuilder().setNsi(NSI_VALUE).build();
+        NxAugMatchNodesNodeTableFlow nxAugMatchNotifUpdateFlowStats = new NxAugMatchNodesNodeTableFlowBuilder()
+                .setNxmNxNsi(nxmNxNsi)
+                .build();
         when(extension.augmentation(Matchers.<Class<Augmentation<Extension>>>any()))
-            .thenReturn(extensionAugmentation);
+                .thenReturn(nxAugMatchNotifUpdateFlowStats);
 
         nsiConvertor = new NsiConvertor();
     }
 
     @Test
-    public void testConvert() throws Exception {
+    public void testConvertToOFJava() {
         final MatchEntry converted = nsiConvertor.convert(extension);
-        Assert.assertEquals(1, ((NsiCaseValue)converted.getMatchEntryValue()).getNsiValues().getNsi().intValue());
+        ExperimenterIdCase experimenterIdCase = (ExperimenterIdCase) converted.getMatchEntryValue();
+        OfjAugNxExpMatch ofjAugNxExpMatch = experimenterIdCase.augmentation(OfjAugNxExpMatch.class);
+        NsiCaseValue nsiCaseValue = (NsiCaseValue) ofjAugNxExpMatch.getNxExpMatchEntryValue();
+        Assert.assertEquals(NiciraConstants.NX_NSH_VENDOR_ID,
+                experimenterIdCase.getExperimenter().getExperimenter().getValue());
+        Assert.assertEquals(NSI_VALUE, nsiCaseValue.getNsiValues().getNsi());
     }
 
     @Test
-    public void testConvert1() throws Exception {
-        final NsiValuesBuilder nsiValuesBuilder = new NsiValuesBuilder()
-                .setNsi(Short.valueOf((short)1));
-        final NsiCaseValueBuilder nsiCaseValueBuilder = new NsiCaseValueBuilder()
-                .setNsiValues(nsiValuesBuilder.build());
-
-        final NsiCaseValue nsiCaseValue = nsiCaseValueBuilder.build();
-
-        when(matchEntry.getMatchEntryValue()).thenReturn(nsiCaseValue);
+    public void testConvertToOFSal() {
+        MatchEntry matchEntry = NsiConvertor.buildMatchEntry(NSI_VALUE, null);
 
         final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment = nsiConvertor.convert(matchEntry,
                 MatchPath.PACKET_RECEIVED_MATCH);
-        Assert.assertEquals(1,
-                ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject()).getNxmNxNsi().getNsi().intValue());
+        Assert.assertEquals(NSI_VALUE,
+                ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject()).getNxmNxNsi().getNsi());
         Assert.assertEquals(extensionAugment.getKey(), NxmNxNsiKey.class);
 
         final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment1 = nsiConvertor.convert(matchEntry,
                 MatchPath.SWITCH_FLOW_REMOVED_MATCH);
-        Assert.assertEquals(1, ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject())
-                .getNxmNxNsi().getNsi().intValue());
+        Assert.assertEquals(NSI_VALUE,
+                ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject()).getNxmNxNsi().getNsi());
         Assert.assertEquals(extensionAugment.getKey(), NxmNxNsiKey.class);
 
         final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment2 = nsiConvertor.convert(matchEntry,
                 MatchPath.FLOWS_STATISTICS_UPDATE_MATCH);
-        Assert.assertEquals(1, ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject()).getNxmNxNsi()
-                .getNsi().intValue());
+        Assert.assertEquals(NSI_VALUE,
+                ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject()).getNxmNxNsi().getNsi());
         Assert.assertEquals(extensionAugment.getKey(), NxmNxNsiKey.class);
 
         final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment3 = nsiConvertor.convert(matchEntry,
                 MatchPath.FLOWS_STATISTICS_RPC_MATCH);
-        Assert.assertEquals(1, ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject()).getNxmNxNsi()
-                .getNsi().intValue());
+        Assert.assertEquals(NSI_VALUE,
+                ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject()).getNxmNxNsi().getNsi());
         Assert.assertEquals(extensionAugment.getKey(), NxmNxNsiKey.class);
     }
 }
+
index 3fe727fb8ff4cb82e5ef68e1ab43b8c8e1e02dd4..b611a2165e8b3671ed6d3f94ccda455867dd6d10 100644 (file)
@@ -17,12 +17,13 @@ import org.junit.runner.RunWith;
 import org.mockito.Matchers;
 import org.mockito.Mock;
 import org.mockito.runners.MockitoJUnitRunner;
+import org.opendaylight.openflowjava.nx.api.NiciraConstants;
 import org.opendaylight.openflowplugin.extension.api.ExtensionAugment;
 import org.opendaylight.openflowplugin.extension.api.path.MatchPath;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsp.grouping.NspValuesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.NspCaseValue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.NspCaseValueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.OfjAugNxExpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NspCaseValue;
 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.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlowBuilder;
@@ -30,6 +31,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifSwitchFlowRemoved;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchRpcGetFlowStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxNspKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsp.grouping.NxmNxNsp;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsp.grouping.NxmNxNspBuilder;
 import org.opendaylight.yangtools.yang.binding.Augmentation;
 
@@ -40,65 +42,61 @@ import org.opendaylight.yangtools.yang.binding.Augmentation;
 public class NspConvertorTest {
     @Mock
     private Extension extension;
-    @Mock
-    private MatchEntry matchEntry;
 
     private NspConvertor nspConvertor;
 
+    private static final Long NSP_VALUE = 0xFFL;
+
     @Before
     public void setUp() throws Exception {
-        final NxmNxNspBuilder nxmNxNspBuilder = new NxmNxNspBuilder()
-                .setValue(Long.valueOf(1L));
-        final NxAugMatchNodesNodeTableFlowBuilder nxAugMatchNotifUpdateFlowStatsBuilder =
-                new NxAugMatchNodesNodeTableFlowBuilder();
-        nxAugMatchNotifUpdateFlowStatsBuilder.setNxmNxNsp(nxmNxNspBuilder.build());
-
-        final Augmentation<Extension> extensionAugmentation = nxAugMatchNotifUpdateFlowStatsBuilder.build();
+        NxmNxNsp nxmNxNsp = new NxmNxNspBuilder().setValue(NSP_VALUE).build();
+        NxAugMatchNodesNodeTableFlow nxAugMatchNotifUpdateFlowStats = new NxAugMatchNodesNodeTableFlowBuilder()
+                .setNxmNxNsp(nxmNxNsp)
+                .build();
         when(extension.augmentation(Matchers.<Class<Augmentation<Extension>>>any()))
-            .thenReturn(extensionAugmentation);
+                .thenReturn(nxAugMatchNotifUpdateFlowStats);
 
         nspConvertor = new NspConvertor();
     }
 
     @Test
-    public void testConvert() throws Exception {
+    public void testConvertToOFJava() {
         final MatchEntry converted = nspConvertor.convert(extension);
-        Assert.assertEquals(1, ((NspCaseValue)converted.getMatchEntryValue()).getNspValues().getNsp().intValue());
+        ExperimenterIdCase experimenterIdCase = (ExperimenterIdCase) converted.getMatchEntryValue();
+        OfjAugNxExpMatch ofjAugNxExpMatch = experimenterIdCase.augmentation(OfjAugNxExpMatch.class);
+        NspCaseValue nspCaseValue = (NspCaseValue) ofjAugNxExpMatch.getNxExpMatchEntryValue();
+        Assert.assertEquals(NiciraConstants.NX_NSH_VENDOR_ID,
+                experimenterIdCase.getExperimenter().getExperimenter().getValue());
+        Assert.assertEquals(NSP_VALUE, nspCaseValue.getNspValues().getNsp());
     }
 
     @Test
-    public void testConvert1() throws Exception {
-        final NspValuesBuilder nspValuesBuilder = new NspValuesBuilder()
-                .setNsp(Long.valueOf(2L));
-        final NspCaseValueBuilder nspCaseValueBuilder = new NspCaseValueBuilder()
-                .setNspValues(nspValuesBuilder.build());
-
-        final NspCaseValue nspCaseValue = nspCaseValueBuilder.build();
-
-        when(matchEntry.getMatchEntryValue()).thenReturn(nspCaseValue);
+    public void testConvertToOFSal() {
+        MatchEntry matchEntry = NspConvertor.buildMatchEntry(NSP_VALUE, null);
 
         final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment = nspConvertor.convert(matchEntry,
                 MatchPath.PACKET_RECEIVED_MATCH);
-        Assert.assertEquals(2, ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject()).getNxmNxNsp()
-                .getValue().longValue());
+        Assert.assertEquals(NSP_VALUE,
+                ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject()).getNxmNxNsp().getValue());
         Assert.assertEquals(extensionAugment.getKey(), NxmNxNspKey.class);
 
         final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment1 = nspConvertor.convert(matchEntry,
                 MatchPath.SWITCH_FLOW_REMOVED_MATCH);
-        Assert.assertEquals(2, ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject())
-                .getNxmNxNsp().getValue().longValue());
+        Assert.assertEquals(NSP_VALUE,
+                ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject())
+                        .getNxmNxNsp().getValue());
         Assert.assertEquals(extensionAugment.getKey(), NxmNxNspKey.class);
 
         final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment2 = nspConvertor.convert(matchEntry,
                 MatchPath.FLOWS_STATISTICS_UPDATE_MATCH);
-        Assert.assertEquals(2, ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject()).getNxmNxNsp()
-                .getValue().longValue());
+        Assert.assertEquals(NSP_VALUE,
+                ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject()).getNxmNxNsp().getValue());
         Assert.assertEquals(extensionAugment.getKey(), NxmNxNspKey.class);
 
         final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment3 = nspConvertor.convert(matchEntry,
                 MatchPath.FLOWS_STATISTICS_RPC_MATCH);
-        Assert.assertEquals(2, ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject()).getNxmNxNsp()
-                .getValue().longValue());
+        Assert.assertEquals(NSP_VALUE,
+                ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject()).getNxmNxNsp().getValue());
         Assert.assertEquals(extensionAugment.getKey(), NxmNxNspKey.class);
     }
 }