Fixed (de)serialization issue
[openflowplugin.git] / extension / openflowjava-extension-nicira / src / main / java / org / opendaylight / openflowjava / nx / codec / match / TunIdCodec.java
index b2f3f449e19745b0f5e79c1212aed9ab5ee29f2f..37f81a348b8f77c1efeebe19d130caac70a41236 100644 (file)
@@ -1,22 +1,22 @@
 package org.opendaylight.openflowjava.nx.codec.match;
 
 import io.netty.buffer.ByteBuf;
+
+import java.math.BigInteger;
+
 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey;
 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.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.OpenflowBasicClass;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TunnelId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TunnelIdCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TunnelIdCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tunnel.id._case.TunnelIdBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxTunId;
-import java.math.BigInteger;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.tun.id.grouping.TunIdValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.TunIdCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.TunIdCaseValueBuilder;
 
 public class TunIdCodec extends AbstractMatchCodec {
 
@@ -30,24 +30,18 @@ public class TunIdCodec extends AbstractMatchCodec {
     @Override
     public void serialize(MatchEntry input, ByteBuf outBuffer) {
         serializeHeader(input, outBuffer);
-        TunnelIdCase value = ((TunnelIdCase) input.getMatchEntryValue());
-        outBuffer.writeBytes(value.getTunnelId().getTunnelId());
-        byte[] mask = value.getTunnelId().getTunnelId();
-        if (null != mask) {
-            outBuffer.writeBytes(mask);
-        }
+        BigInteger value = ((TunIdCaseValue) input.getMatchEntryValue()).getTunIdValues().getValue();
+        outBuffer.writeLong(value.longValue());
     }
 
     @Override
     public MatchEntry deserialize(ByteBuf message) {
         MatchEntryBuilder matchEntriesBuilder = deserializeHeader(message);
-        TunnelIdCaseBuilder tunnelIdCaseBuilder = new TunnelIdCaseBuilder();
-        TunnelIdBuilder tunnelIdBuilder = new TunnelIdBuilder();
-        tunnelIdBuilder.setTunnelId(BigInteger.valueOf(message.readLong()).toByteArray());
-        tunnelIdCaseBuilder.setTunnelId(tunnelIdBuilder.build());
-        matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
-        matchEntriesBuilder.setOxmMatchField(TunnelId.class);
-        matchEntriesBuilder.setMatchEntryValue(tunnelIdCaseBuilder.build());
+        TunIdCaseValueBuilder caseBuilder = new TunIdCaseValueBuilder();
+        TunIdValuesBuilder tunIdBuilder = new TunIdValuesBuilder();
+        tunIdBuilder.setValue(BigInteger.valueOf(message.readLong()));
+        caseBuilder.setTunIdValues(tunIdBuilder.build());
+        matchEntriesBuilder.setMatchEntryValue(caseBuilder.build());
         return matchEntriesBuilder.build();
     }