Created experimenter subtype for vendor's actions 29/9429/6
authorMartin Sunal <msunal@cisco.com>
Tue, 29 Jul 2014 10:21:56 +0000 (12:21 +0200)
committerMartin Sunal <msunal@cisco.com>
Wed, 30 Jul 2014 09:22:31 +0000 (11:22 +0200)
ExperimenterActionSerializerKey has a new parameter which is type of vendor's action.
It allows to select right serializer directly in OFJava so a vendor does not need to care about it.
- created codec for Nicira match nxm_of_eth_type

Change-Id: Id9bc0f06820cab7b897eb710a70ddc3d6af13a45
Signed-off-by: Martin Sunal <msunal@cisco.com>
20 files changed:
openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraExtensionsRegistrator.java
openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraMatchCodecs.java
openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/AbstractActionSerializer.java [new file with mode: 0644]
openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ActionDeserializer.java [moved from openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ActionCodec.java with 55% similarity]
openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/NiciraActionCodecs.java [new file with mode: 0644]
openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegLoadCodec.java
openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegMoveCodec.java
openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpTpaCodec.java
openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthDstCodec.java
openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthTypeCodec.java [new file with mode: 0644]
openflow-extension-nicira/src/main/yang/nicira-action.yang
openflow-extension-nicira/src/main/yang/nicira-match.yang
openflow-nx-resubmit-action/src/main/java/org/opendaylight/openflowjava/protocol/nx/NxResubmitActionRegistrator.java
openflow-nx-resubmit-action/src/main/yang/nx-resubmit-action.yang
openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java
openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java
openflow-protocol-api/src/main/yang/openflow-action.yang
openflow-protocol-api/src/main/yang/openflow-augments.yang
openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/extensibility/KeysTest.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java

index 551b9e9d109d173d7b8de1756c9bb7e6d450101f..1ed72236f054e79179c2e6b00b57e50434f69a89 100644 (file)
@@ -2,7 +2,10 @@ package org.opendaylight.openflowjava.nx;
 
 import java.util.List;
 
-import org.opendaylight.openflowjava.nx.codec.action.ActionCodec;
+import org.opendaylight.openflowjava.nx.codec.action.ActionDeserializer;
+import org.opendaylight.openflowjava.nx.codec.action.NiciraActionCodecs;
+import org.opendaylight.openflowjava.nx.codec.action.RegLoadCodec;
+import org.opendaylight.openflowjava.nx.codec.action.RegMoveCodec;
 import org.opendaylight.openflowjava.nx.codec.match.ArpOpCodec;
 import org.opendaylight.openflowjava.nx.codec.match.ArpShaCodec;
 import org.opendaylight.openflowjava.nx.codec.match.ArpSpaCodec;
@@ -10,6 +13,7 @@ import org.opendaylight.openflowjava.nx.codec.match.ArpThaCodec;
 import org.opendaylight.openflowjava.nx.codec.match.ArpTpaCodec;
 import org.opendaylight.openflowjava.nx.codec.match.EthDstCodec;
 import org.opendaylight.openflowjava.nx.codec.match.EthSrcCodec;
+import org.opendaylight.openflowjava.nx.codec.match.EthTypeCodec;
 import org.opendaylight.openflowjava.nx.codec.match.Reg0Codec;
 import org.opendaylight.openflowjava.nx.codec.match.Reg1Codec;
 import org.opendaylight.openflowjava.nx.codec.match.Reg2Codec;
@@ -27,7 +31,6 @@ import com.google.common.base.Preconditions;
 
 public class NiciraExtensionsRegistrator implements AutoCloseable {
 
-    private static final ActionCodec ACTION_CODEC = new ActionCodec();
     private final List<SwitchConnectionProvider> providers;
 
     /**
@@ -40,8 +43,9 @@ public class NiciraExtensionsRegistrator implements AutoCloseable {
 
     public void registerNiciraExtensions() {
         for (SwitchConnectionProvider provider : providers) {
-            provider.registerActionDeserializer(ActionCodec.DESERIALIZER_KEY, ACTION_CODEC);
-            provider.registerActionSerializer(ActionCodec.SERIALIZER_KEY, ACTION_CODEC);
+            provider.registerActionDeserializer(ActionDeserializer.DESERIALIZER_KEY, NiciraActionCodecs.ACTION_DESERIALIZER);
+            provider.registerActionSerializer(RegLoadCodec.SERIALIZER_KEY, NiciraActionCodecs.REG_LOAD_CODEC);
+            provider.registerActionSerializer(RegMoveCodec.SERIALIZER_KEY, NiciraActionCodecs.REG_MOVE_CODEC);
             provider.registerMatchEntrySerializer(Reg0Codec.SERIALIZER_KEY, NiciraMatchCodecs.REG0_CODEC);
             provider.registerMatchEntryDeserializer(Reg0Codec.DESERIALIZER_KEY, NiciraMatchCodecs.REG0_CODEC);
             provider.registerMatchEntrySerializer(Reg1Codec.SERIALIZER_KEY, NiciraMatchCodecs.REG1_CODEC);
@@ -78,13 +82,16 @@ public class NiciraExtensionsRegistrator implements AutoCloseable {
             provider.registerMatchEntryDeserializer(TunIpv4DstCodec.DESERIALIZER_KEY, NiciraMatchCodecs.TUN_IPV4_DST_CODEC);
             provider.registerMatchEntrySerializer(TunIpv4SrcCodec.SERIALIZER_KEY, NiciraMatchCodecs.TUN_IPV4_SRC_CODEC);
             provider.registerMatchEntryDeserializer(TunIpv4SrcCodec.DESERIALIZER_KEY, NiciraMatchCodecs.TUN_IPV4_SRC_CODEC);
+            provider.registerMatchEntrySerializer(EthTypeCodec.SERIALIZER_KEY, NiciraMatchCodecs.ETH_TYPE_CODEC);
+            provider.registerMatchEntryDeserializer(EthTypeCodec.DESERIALIZER_KEY, NiciraMatchCodecs.ETH_TYPE_CODEC);
         }
     }
 
     public void unregisterExtensions() {
         for (SwitchConnectionProvider provider : providers) {
-            provider.unregisterSerializer(ActionCodec.SERIALIZER_KEY);
-            provider.unregisterDeserializer(ActionCodec.DESERIALIZER_KEY);
+            provider.unregisterDeserializer(ActionDeserializer.DESERIALIZER_KEY);
+            provider.unregisterSerializer(RegLoadCodec.SERIALIZER_KEY);
+            provider.unregisterSerializer(RegMoveCodec.SERIALIZER_KEY);
             provider.unregisterSerializer(Reg0Codec.SERIALIZER_KEY);
             provider.unregisterDeserializer(Reg0Codec.DESERIALIZER_KEY);
             provider.unregisterSerializer(Reg1Codec.SERIALIZER_KEY);
@@ -121,6 +128,8 @@ public class NiciraExtensionsRegistrator implements AutoCloseable {
             provider.unregisterDeserializer(TunIpv4DstCodec.DESERIALIZER_KEY);
             provider.unregisterSerializer(TunIpv4SrcCodec.SERIALIZER_KEY);
             provider.unregisterDeserializer(TunIpv4SrcCodec.DESERIALIZER_KEY);
+            provider.unregisterSerializer(EthTypeCodec.SERIALIZER_KEY);
+            provider.unregisterDeserializer(EthTypeCodec.DESERIALIZER_KEY);
         }
     }
 
index 0e166ba8a82d9adcda93d17ce38ab0ff03fd4956..b9422f51925229887d06e1742723b423ba41bcfb 100644 (file)
@@ -14,6 +14,7 @@ import org.opendaylight.openflowjava.nx.codec.match.ArpThaCodec;
 import org.opendaylight.openflowjava.nx.codec.match.ArpTpaCodec;
 import org.opendaylight.openflowjava.nx.codec.match.EthDstCodec;
 import org.opendaylight.openflowjava.nx.codec.match.EthSrcCodec;
+import org.opendaylight.openflowjava.nx.codec.match.EthTypeCodec;
 import org.opendaylight.openflowjava.nx.codec.match.Reg0Codec;
 import org.opendaylight.openflowjava.nx.codec.match.Reg1Codec;
 import org.opendaylight.openflowjava.nx.codec.match.Reg2Codec;
@@ -50,5 +51,6 @@ public class NiciraMatchCodecs {
     public static final EthSrcCodec ETH_SRC_CODEC = new EthSrcCodec();
     public static final TunIpv4DstCodec TUN_IPV4_DST_CODEC = new TunIpv4DstCodec();
     public static final TunIpv4SrcCodec TUN_IPV4_SRC_CODEC = new TunIpv4SrcCodec();
+    public static final EthTypeCodec ETH_TYPE_CODEC = new EthTypeCodec();
 
 }
diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/AbstractActionSerializer.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/AbstractActionSerializer.java
new file mode 100644 (file)
index 0000000..b141d5c
--- /dev/null
@@ -0,0 +1,34 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ * 
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.nx.codec.action;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.nx.NiciraConstants;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
+
+/**
+ * @author msunal
+ *
+ */
+public abstract class AbstractActionSerializer implements OFSerializer<Action> {
+
+    protected final static void serializeHeader(int msgLength, int subtype, ByteBuf outBuffer) {
+        outBuffer.writeShort(EncodeConstants.EXPERIMENTER_VALUE);
+        writeMsgLengthVendorIdSubtypeToBuffer(msgLength, subtype, outBuffer);
+    }
+
+    private final static void writeMsgLengthVendorIdSubtypeToBuffer(int msgLength, int subtype, ByteBuf outBuffer) {
+        outBuffer.writeShort(msgLength);
+        outBuffer.writeInt(NiciraConstants.NX_VENDOR_ID.intValue());
+        outBuffer.writeShort(subtype);
+    }
+
+}
similarity index 55%
rename from openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ActionCodec.java
rename to openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ActionDeserializer.java
index 3d58439cc93fc22273d3e62b2aa55588e2080d89..43e3de0924aae4c93d169335198fdf766745ad71 100644 (file)
@@ -4,9 +4,7 @@ import io.netty.buffer.ByteBuf;
 
 import org.opendaylight.openflowjava.nx.NiciraConstants;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
-import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
 import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey;
-import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdAction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdActionBuilder;
@@ -14,44 +12,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev1
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.NxmNxRegLoad;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.NxmNxRegMove;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.OfjAugNxAction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.OfjAugNxActionBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class ActionCodec implements OFSerializer<Action>, OFDeserializer<Action> {
+public class ActionDeserializer implements OFDeserializer<Action> {
 
-    private static final Logger LOG = LoggerFactory.getLogger(ActionCodec.class);
+    private static final Logger LOG = LoggerFactory.getLogger(ActionDeserializer.class);
 
-    public static final ExperimenterActionSerializerKey SERIALIZER_KEY = new ExperimenterActionSerializerKey(EncodeConstants.OF13_VERSION_ID, NiciraConstants.NX_VENDOR_ID); 
-    public static final ExperimenterActionDeserializerKey DESERIALIZER_KEY = new ExperimenterActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, NiciraConstants.NX_VENDOR_ID);
-    private static final RegMoveCodec regMoveCodec = new RegMoveCodec();
-    private static final RegLoadCodec regLoadCodec = new RegLoadCodec();
-    
-    @Override
-    public void serialize(Action input, ByteBuf outBuffer) {
-        outBuffer.writeShort(EncodeConstants.EXPERIMENTER_VALUE);
-        OfjAugNxAction augNxAction = input.getAugmentation(OfjAugNxAction.class);
-        if (augNxAction == null) {
-            LOG.info("Action {} does not have any serializer.", input.getClass());
-            return;
-        }
-        if (augNxAction.getActionRegMove() != null) {
-            writeMsgLengthVendorIdSubtypeToBuffer(RegMoveCodec.LENGTH, RegMoveCodec.SUBTYPE, outBuffer);
-            regMoveCodec.serialize(augNxAction.getActionRegMove(), outBuffer);
-        } else if (augNxAction.getActionRegLoad() != null) {
-            writeMsgLengthVendorIdSubtypeToBuffer(RegLoadCodec.LENGTH, RegLoadCodec.SUBTYPE, outBuffer);
-            regLoadCodec.serialize(augNxAction.getActionRegLoad(), outBuffer);
-        } else {
-            LOG.info("Action {} does not have any serializer.", input.getClass());
-        }
-    }
-
-    private final static void writeMsgLengthVendorIdSubtypeToBuffer(int msgLength, int subtype, ByteBuf outBuffer) {
-        outBuffer.writeShort(msgLength);
-        outBuffer.writeInt(NiciraConstants.NX_VENDOR_ID.intValue());
-        outBuffer.writeShort(subtype);
-    }
+    public static final ExperimenterActionDeserializerKey DESERIALIZER_KEY = new ExperimenterActionDeserializerKey(
+            EncodeConstants.OF13_VERSION_ID, NiciraConstants.NX_VENDOR_ID);
 
     @Override
     public Action deserialize(ByteBuf message) {
@@ -65,10 +38,12 @@ public class ActionCodec implements OFSerializer<Action>, OFDeserializer<Action>
         OfjAugNxActionBuilder augNxActionBuilder = new OfjAugNxActionBuilder();
         switch (subtype) {
         case RegMoveCodec.SUBTYPE:
-            augNxActionBuilder.setActionRegMove(regMoveCodec.deserialize(message));
+            augNxActionBuilder.setActionRegMove(NiciraActionCodecs.REG_MOVE_CODEC.deserialize(message));
+            expIdBuilder.setSubType(NxmNxRegMove.class);
             break;
         case RegLoadCodec.SUBTYPE:
-            augNxActionBuilder.setActionRegLoad(regLoadCodec.deserialize(message));
+            augNxActionBuilder.setActionRegLoad(NiciraActionCodecs.REG_LOAD_CODEC.deserialize(message));
+            expIdBuilder.setSubType(NxmNxRegLoad.class);
             break;
         default:
             LOG.info("Action {} does not have any deserializer.", subtype);
diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/NiciraActionCodecs.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/NiciraActionCodecs.java
new file mode 100644 (file)
index 0000000..877b677
--- /dev/null
@@ -0,0 +1,19 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ * 
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.nx.codec.action;
+
+/**
+ * @author msunal
+ *
+ */
+public class NiciraActionCodecs {
+
+    public static final RegMoveCodec REG_MOVE_CODEC = new RegMoveCodec();
+    public static final RegLoadCodec REG_LOAD_CODEC = new RegLoadCodec();
+    public static final ActionDeserializer ACTION_DESERIALIZER = new ActionDeserializer();
+}
index 0776edd41b27d517a76303a58fc440bea565ee2a..0ccfa881e7637b99e8bfb1d95e6dbf8897870c19 100644 (file)
@@ -4,21 +4,30 @@ import io.netty.buffer.ByteBuf;
 
 import java.math.BigInteger;
 
+import org.opendaylight.openflowjava.nx.NiciraConstants;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
-import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.NxmNxRegLoad;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.OfjAugNxAction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.ofj.nx.action.reg.load.grouping.ActionRegLoad;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.ofj.nx.action.reg.load.grouping.ActionRegLoadBuilder;
 
-public class RegLoadCodec implements OFSerializer<ActionRegLoad>, OFDeserializer<ActionRegLoad> {
+public class RegLoadCodec extends AbstractActionSerializer implements OFDeserializer<ActionRegLoad> {
 
+    public static final ExperimenterActionSerializerKey SERIALIZER_KEY = new ExperimenterActionSerializerKey(
+            EncodeConstants.OF13_VERSION_ID, NiciraConstants.NX_VENDOR_ID, NxmNxRegLoad.class);
     public static final int LENGTH = 24;
     public static final byte SUBTYPE = 7; // NXAST_REG_LOAD
 
     @Override
-    public void serialize(ActionRegLoad input, ByteBuf outBuffer) {
-        outBuffer.writeShort(input.getOfsNbits());
-        outBuffer.writeInt(input.getDst().intValue());
-        outBuffer.writeLong(input.getValue().longValue());
+    public void serialize(Action input, ByteBuf outBuffer) {
+        ActionRegLoad actionRegLoad = input.getAugmentation(OfjAugNxAction.class).getActionRegLoad();
+        serializeHeader(LENGTH, SUBTYPE, outBuffer);
+        outBuffer.writeShort(actionRegLoad.getOfsNbits());
+        outBuffer.writeInt(actionRegLoad.getDst().intValue());
+        outBuffer.writeLong(actionRegLoad.getValue().longValue());
     }
 
     @Override
index c7965880d3778e1cd71bf52ad571ed6f1469aefb..f9bf871697d322df1956550398a56d84def4c541 100644 (file)
@@ -2,23 +2,32 @@ package org.opendaylight.openflowjava.nx.codec.action;
 
 import io.netty.buffer.ByteBuf;
 
+import org.opendaylight.openflowjava.nx.NiciraConstants;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
-import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.NxmNxRegMove;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.OfjAugNxAction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.ofj.nx.action.reg.move.grouping.ActionRegMove;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.ofj.nx.action.reg.move.grouping.ActionRegMoveBuilder;
 
-public class RegMoveCodec implements OFSerializer<ActionRegMove>, OFDeserializer<ActionRegMove> {
+public class RegMoveCodec extends AbstractActionSerializer implements OFDeserializer<ActionRegMove> {
 
+    public static final ExperimenterActionSerializerKey SERIALIZER_KEY = new ExperimenterActionSerializerKey(
+            EncodeConstants.OF13_VERSION_ID, NiciraConstants.NX_VENDOR_ID, NxmNxRegMove.class);
     public static final int LENGTH = 24;
     public static final byte SUBTYPE = 6; // NXAST_REG_MOVE
 
     @Override
-    public void serialize(ActionRegMove input, ByteBuf outBuffer) {
-        outBuffer.writeShort(input.getNBits());
-        outBuffer.writeShort(input.getSrcOfs());
-        outBuffer.writeShort(input.getDstOfs());
-        outBuffer.writeInt(input.getSrc().intValue());
-        outBuffer.writeInt(input.getDst().intValue());
+    public void serialize(Action input, ByteBuf outBuffer) {
+        ActionRegMove actionRegMove = input.getAugmentation(OfjAugNxAction.class).getActionRegMove();
+        serializeHeader(LENGTH, SUBTYPE, outBuffer);
+        outBuffer.writeShort(actionRegMove.getNBits());
+        outBuffer.writeShort(actionRegMove.getSrcOfs());
+        outBuffer.writeShort(actionRegMove.getDstOfs());
+        outBuffer.writeInt(actionRegMove.getSrc().intValue());
+        outBuffer.writeInt(actionRegMove.getDst().intValue());
     }
 
     @Override
index 04fc5ad1a58043865ddb3a0a1a990b66ce93bda4..6962a52976839f012efcdc86242b1bad79e1092d 100644 (file)
@@ -19,7 +19,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.
 public class ArpTpaCodec extends AbstractMatchCodec {
 
     private static final int VALUE_LENGTH = 4;
-    private static final int NXM_FIELD_CODE = 16;
+    private static final int NXM_FIELD_CODE = 17;
     public static final MatchEntrySerializerKey<Nxm0Class, NxmOfArpTpa> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
             EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfArpTpa.class);
     public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
index dacbe1f87630b1892a9ef1b10a2ab5bcc5267bcf..9c25f936ace1e1ffdc5a473b7a278739206ddd5e 100644 (file)
@@ -21,7 +21,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.
 public class EthDstCodec extends AbstractMatchCodec {
 
     private static final int VALUE_LENGTH = 6;
-    private static final int NXM_FIELD_CODE = 2;
+    private static final int NXM_FIELD_CODE = 1;
     public static final MatchEntrySerializerKey<Nxm0Class, NxmOfEthDst> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
             EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfEthDst.class);
     public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthTypeCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthTypeCodec.java
new file mode 100644 (file)
index 0000000..4eccd37
--- /dev/null
@@ -0,0 +1,69 @@
+package org.opendaylight.openflowjava.nx.codec.match;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey;
+import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmOfEthType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.ofj.nxm.of.match.eth.type.grouping.EthTypeValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm0Class;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;
+
+public class EthTypeCodec extends AbstractMatchCodec {
+
+    private static final int VALUE_LENGTH = 2;
+    private static final int NXM_FIELD_CODE = 3;
+    public static final MatchEntrySerializerKey<Nxm0Class, NxmOfEthType> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
+            EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfEthType.class);
+    public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
+            EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, NXM_FIELD_CODE);
+
+    @Override
+    public void serialize(MatchEntries input, ByteBuf outBuffer) {
+        serializeHeader(input, outBuffer);
+        Integer value = input.getAugmentation(OfjAugNxMatch.class).getEthTypeValues().getValue();
+        outBuffer.writeShort(value);
+    }
+
+    @Override
+    public MatchEntries deserialize(ByteBuf message) {
+        MatchEntriesBuilder matchEntriesBuilder = deserializeHeader(message);
+        OfjAugNxMatchBuilder augNxMatchBuilder = new OfjAugNxMatchBuilder();
+        augNxMatchBuilder.setEthTypeValues(new EthTypeValuesBuilder().setValue(message.readUnsignedShort()).build());
+        matchEntriesBuilder.addAugmentation(OfjAugNxMatch.class, augNxMatchBuilder.build());
+        return matchEntriesBuilder.build();
+    }
+
+    @Override
+    public int getNxmFieldCode() {
+        return NXM_FIELD_CODE;
+    }
+
+    @Override
+    public int getOxmClassCode() {
+        return OxmMatchConstants.NXM_0_CLASS;
+    }
+
+    @Override
+    public int getValueLength() {
+        return VALUE_LENGTH;
+    }
+
+    @Override
+    public Class<? extends MatchField> getNxmField() {
+        return NxmOfEthType.class;
+    }
+
+    @Override
+    public Class<? extends OxmClassBase> getOxmClass() {
+        return Nxm0Class.class;
+    }
+
+}
index 7bb5faf7d0be768432042a3729b4b4e8930e6743..c43b1520317e4d59b84b02044656aad1f873fcb3 100644 (file)
@@ -14,6 +14,13 @@ module nicira-action {
     revision "2014-04-21" {
         description "Initial revision";
     }
+    
+    identity nxm-nx-reg-load {
+        base ofaction:experimenter-action-sub-type;
+    }
+    identity nxm-nx-reg-move {
+        base ofaction:experimenter-action-sub-type;
+    }
 
     grouping ofj-nx-action-reg-load-grouping {
         container action-reg-load {
index edf8a3a335ffb7fc4217576f0e8c01dae5c47772..3bff0351212db96c1fc31b3ce0f4694dfa1d1c84 100644 (file)
@@ -74,6 +74,9 @@ module nicira-match {
     identity nxm-of-eth-dst {
         base ofoxm:match-field;
     }
+    identity nxm-of-eth-type {
+        base ofoxm:match-field;
+    }
 
     grouping ofj-nxm-nx-match-reg-grouping {
         container reg-values {
@@ -152,6 +155,13 @@ module nicira-match {
             }
         }
     }
+    grouping ofj-nxm-of-match-eth-type-grouping {
+        container eth-type-values {
+            leaf value {
+                type uint16;
+            }
+        }
+    }
 
     augment "/ofoxm:oxm-container/ofoxm:match-entries" {
         ext:augment-identifier "ofj-aug_nx_match";
@@ -166,6 +176,7 @@ module nicira-match {
         uses ofj-nxm-nx-match-tun-ipv4-src-grouping;
         uses ofj-nxm-of-match-eth-src-grouping;
         uses ofj-nxm-of-match-eth-dst-grouping;
+        uses ofj-nxm-of-match-eth-type-grouping;
     }
 
 }
\ No newline at end of file
index 4baf6d2dc1cb2840c276ad3793309b5bc5b1e3a9..a9a04a5328ef392f26ca8ec0837ac0965374aea1 100644 (file)
@@ -16,6 +16,7 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.nx.deserialization.NxActionResubmitDeserializer;\r
 import org.opendaylight.openflowjava.protocol.nx.serialization.NxActionResubmitSerializer;\r
 import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.nx.resubmit.action.rev130731.NxResubmitAction;\r
 \r
 /**\r
  * @author michal.polkorab\r
@@ -34,17 +35,8 @@ public class NxResubmitActionRegistrator implements AutoCloseable {
         if (providers != null) {\r
             this.providers = providers;\r
             for (SwitchConnectionProvider provider : providers) {\r
-                /* In case of handling multiple actions, instructions and other structures which\r
-                 * are differentiated by vendor / experimenter subtype, vendor has to\r
-                 * switch / choose between these subtypes.\r
-                 * \r
-                 * This has to be done in this way because of experimenter headers, which\r
-                 * provide only vendor / experimenter ID. Subtype position may be different\r
-                 * for different vendors (or not present at all) - that's why vendor has to\r
-                 * handle it in his own implementations.\r
-                 */\r
                 provider.registerActionSerializer(new ExperimenterActionSerializerKey(\r
-                        EncodeConstants.OF13_VERSION_ID, NICIRA_EXPERIMENTER_ID),\r
+                        EncodeConstants.OF13_VERSION_ID, NICIRA_EXPERIMENTER_ID, NxResubmitAction.class),\r
                         new NxActionResubmitSerializer());\r
             }\r
         }\r
@@ -78,7 +70,7 @@ public class NxResubmitActionRegistrator implements AutoCloseable {
         for (SwitchConnectionProvider provider : providers) {\r
             // unregister serializer\r
             provider.unregisterSerializer(new ExperimenterActionSerializerKey(\r
-                    EncodeConstants.OF13_VERSION_ID, NICIRA_EXPERIMENTER_ID));\r
+                    EncodeConstants.OF13_VERSION_ID, NICIRA_EXPERIMENTER_ID, NxResubmitAction.class));\r
             // unregister deserializer\r
             provider.unregisterDeserializer(new ExperimenterActionDeserializerKey(\r
                     EncodeConstants.OF13_VERSION_ID, NICIRA_EXPERIMENTER_ID));\r
index 5ab94cd158fe161dc2e90de71828333c064c235e..418611b5cc06fcc3b6e06bc9af33577ceeaea29c 100644 (file)
     revision "2013-07-31" {\r
         description "OpenFlow 1.3 - action model";\r
     }\r
+    \r
+    identity nx-resubmit-action {\r
+        base ofaction:experimenter-action-sub-type;\r
+    }\r
 \r
     augment "/ofaction:actions-container/ofaction:action" {\r
          ext:augment-identifier "nx-action-resubmit-augment";\r
index 38b8cd498d075199a3b9f2d7ad294e757e317ed3..bf1fe7dcb92d307d034ea0ed9fdb3a48fb7d168c 100644 (file)
@@ -48,7 +48,7 @@ public class ActionSerializerKey<TYPE extends ActionBase> extends MessageTypeKey
             return true;\r
         if (!super.equals(obj))\r
             return false;\r
-        if (!(obj instanceof ActionSerializerKey))\r
+        if (getClass() != obj.getClass())\r
             return false;\r
         ActionSerializerKey<?> other = (ActionSerializerKey<?>) obj;\r
         if (actionType == null) {\r
index 989e1ba769a8d3d2a8dfe653191406c8df897b49..be18643c6da584aced10cb95770aaa2f3c82c5cf 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.openflowjava.protocol.api.keys.experimenter;
 \r
 import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.ExperimenterActionSubType;\r
 \r
 /**\r
  * @author michal.polkorab\r
@@ -17,12 +18,40 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev1
 public final class ExperimenterActionSerializerKey extends ActionSerializerKey<Experimenter> \r
         implements ExperimenterSerializerKey {\r
 \r
+    private Class<? extends ExperimenterActionSubType> actionSubType;\r
+\r
     /**\r
      * @param msgVersion protocol wire version\r
      * @param experimenterId experimenter / vendor ID\r
      */\r
-    public ExperimenterActionSerializerKey(short msgVersion, Long experimenterId) {\r
+    public ExperimenterActionSerializerKey(short msgVersion, Long experimenterId, Class<? extends ExperimenterActionSubType> actionSubType) {\r
         super(msgVersion, Experimenter.class, experimenterId);\r
+        this.actionSubType = actionSubType;\r
+    }\r
+\r
+    @Override\r
+    public int hashCode() {\r
+        final int prime = 31;\r
+        int result = super.hashCode();\r
+        result = prime * result + ((actionSubType == null) ? 0 : actionSubType.hashCode());\r
+        return result;\r
+    }\r
+\r
+    @Override\r
+    public boolean equals(Object obj) {\r
+        if (this == obj)\r
+            return true;\r
+        if (!super.equals(obj))\r
+            return false;\r
+        if (getClass() != obj.getClass())\r
+            return false;\r
+        ExperimenterActionSerializerKey other = (ExperimenterActionSerializerKey) obj;\r
+        if (actionSubType == null) {\r
+            if (other.actionSubType != null)\r
+                return false;\r
+        } else if (!actionSubType.equals(other.actionSubType))\r
+            return false;\r
+        return true;\r
     }\r
 \r
 }
\ No newline at end of file
index 9cc200c4bca021713abc24355759d0eac6e65a72..482c122803fc6d01193829351ecdc95efd56edf5 100644 (file)
         description "";
         base oft:action-base;
     }
-    
+
+    identity experimenter-action-sub-type {
+        description "The base identity for vendor's actions.";
+    }
+
     container actions-container {
         uses actions-grouping;
     }
index 910dfa5fe0fd97eb049983fcc9b3a7f0fa5ec451..a2e69293ca6eb6c66e3e27a292ffbf4f7ff85bb1 100644 (file)
          leaf experimenter {\r
              type oft:experimenter-id;\r
          }\r
+         leaf sub-type {\r
+            type identityref {\r
+                base ofaction:experimenter-action-sub-type;\r
+            }\r
+         }\r
      }\r
      // OF1.0 structures\r
      augment "/ofaction:actions-container/ofaction:action" {\r
index 9b4cf744321b33d008590e8c68d95dd486584eb4..0093e9c83fc8efb05d65f06fd0481e5c6eda6a6d 100644 (file)
@@ -13,6 +13,7 @@ import org.opendaylight.openflowjava.protocol.api.keys.experimenter.Experimenter
 import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.ExperimenterActionSubType;
 
 /**
  * @author michal.polkorab
@@ -49,9 +50,9 @@ public class KeysTest {
         ActionSerializerKey<Experimenter> actionSerializerKey = new ActionSerializerKey<>(
                 EncodeConstants.OF13_VERSION_ID, Experimenter.class, 1L);
         ExperimenterActionSerializerKey experimenterActionSerializerKey = new ExperimenterActionSerializerKey(
-                EncodeConstants.OF13_VERSION_ID, 1L);
-        Assert.assertEquals(actionSerializerKey, experimenterActionSerializerKey);
-        Assert.assertEquals(actionSerializerKey.hashCode(), experimenterActionSerializerKey.hashCode());
+                EncodeConstants.OF13_VERSION_ID, 1L, ExpSubType.class);
+        Assert.assertFalse(actionSerializerKey.equals(experimenterActionSerializerKey));
+        Assert.assertFalse(experimenterActionSerializerKey.equals(actionSerializerKey));
 
         InstructionSerializerKey<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter> instructionSerializerKey = new InstructionSerializerKey<>(
                 EncodeConstants.OF13_VERSION_ID,
@@ -61,5 +62,9 @@ public class KeysTest {
         Assert.assertEquals(instructionSerializerKey, experimenterInstructionSerializerKey);
         Assert.assertEquals(instructionSerializerKey.hashCode(), experimenterInstructionSerializerKey.hashCode());
     }
+    
+    private static class ExpSubType extends ExperimenterActionSubType {
+        
+    }
 
 }
index 6530ee2c57de37d86f47cacaa98fa9ab2db1206b..1d3875df7a6f7f36a55d29940fa8e4ee92341650 100644 (file)
@@ -63,7 +63,7 @@ public abstract class TypeKeyMakerFactory {
             public MessageTypeKey<?> make(Action entry) {\r
                 if (entry.getType().equals(Experimenter.class)) {\r
                     return new ExperimenterActionSerializerKey(getVersion(),\r
-                            entry.getAugmentation(ExperimenterIdAction.class).getExperimenter().getValue());\r
+                            entry.getAugmentation(ExperimenterIdAction.class).getExperimenter().getValue(), entry.getAugmentation(ExperimenterIdAction.class).getSubType());\r
                 }\r
                 return new ActionSerializerKey<>(getVersion(), entry.getType(), null);\r
             }\r