Add Action deserializers 43/49943/23
authorTomas Slusny <tomas.slusny@pantheon.tech>
Mon, 2 Jan 2017 09:01:30 +0000 (10:01 +0100)
committerTomas Slusny <tomas.slusny@pantheon.tech>
Wed, 15 Feb 2017 15:13:41 +0000 (16:13 +0100)
Inject action deserializers into DeserializerRegistry.
These deserializers will deserialize these actions:

 - CopyTtlIn
 - CopyTtlOut
 - DecMplsTtl
 - DecNwTtl
 - Group
 - Output
 - PopMpls
 - PopPbb
 - PopVlan
 - PushMpls
 - PushPbb
 - PushVlan
 - SetField
 - SetMplsTtl
 - SetNwTtl
 - SetQueue

See also: bug 7140

Change-Id: I0f36092ca99de0ca51719c3c2099ebe1d904a72f
Signed-off-by: Tomas Slusny <tomas.slusny@pantheon.tech>
33 files changed:
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/ActionDeserializerInjector.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/CopyTtlInActionDeserializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/CopyTtlOutActionDeserializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/DecMplsTtlActionDeserializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/DecNwTtlActionDeserializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/GroupActionDeserializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/OutputActionDeserializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PopMplsActionDeserializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PopPbbActionDeserializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PopVlanActionDeserializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PushMplsActionDeserializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PushPbbActionDeserializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PushVlanActionDeserializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/SetFieldActionDeserializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/SetMplsTtlActionDeserializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/SetNwTtlActionDeserializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/SetQueueActionDeserializer.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/CopyTtlInActionDeserializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/CopyTtlOutActionDeserializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/DecMplsTtlActionDeserializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/DecNwTtlActionDeserializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/GroupActionDeserializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/OutputActionDeserializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PopMplsActionDeserializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PopPbbActionDeserializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PopVlanActionDeserializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PushMplsActionDeserializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PushPbbActionDeserializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PushVlanActionDeserializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/SetFieldActionDeserializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/SetMplsTtlActionDeserializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/SetNwTtlActionDeserializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/SetQueueActionDeserializerTest.java [new file with mode: 0644]

index 133404fb9949f424305341757b3c4d60bbf78bae..c87190852c3aa47129f86bd931c9fbf211fed437 100644 (file)
@@ -14,7 +14,24 @@ import java.util.function.Function;
 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerExtensionProvider;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
 import org.opendaylight.openflowplugin.api.openflow.protocol.deserialization.MessageCodeExperimenterKey;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.action.CopyTtlInActionDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.action.CopyTtlOutActionDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.action.DecMplsTtlActionDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.action.DecNwTtlActionDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.action.GroupActionDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.action.OutputActionDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.action.PopMplsActionDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.action.PopPbbActionDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.action.PopVlanActionDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.action.PushMplsActionDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.action.PushPbbActionDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.action.PushVlanActionDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.action.SetFieldActionDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.action.SetMplsTtlActionDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.action.SetNwTtlActionDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.action.SetQueueActionDeserializer;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
 
 import com.google.common.annotations.VisibleForTesting;
@@ -29,6 +46,23 @@ public class ActionDeserializerInjector {
         // Inject new message deserializers here using injector created by createInjector method
         final Function<Byte, Consumer<OFDeserializer<Action>>> injector =
                 createInjector(provider, EncodeConstants.OF13_VERSION_ID);
+
+        injector.apply(ActionConstants.COPY_TTL_IN_CODE).accept(new CopyTtlInActionDeserializer());
+        injector.apply(ActionConstants.COPY_TTL_OUT_CODE).accept(new CopyTtlOutActionDeserializer());
+        injector.apply(ActionConstants.OUTPUT_CODE).accept(new OutputActionDeserializer());
+        injector.apply(ActionConstants.DEC_MPLS_TTL_CODE).accept(new DecMplsTtlActionDeserializer());
+        injector.apply(ActionConstants.DEC_NW_TTL_CODE).accept(new DecNwTtlActionDeserializer());
+        injector.apply(ActionConstants.GROUP_CODE).accept(new GroupActionDeserializer());
+        injector.apply(ActionConstants.POP_MPLS_CODE).accept(new PopMplsActionDeserializer());
+        injector.apply(ActionConstants.POP_PBB_CODE).accept(new PopPbbActionDeserializer());
+        injector.apply(ActionConstants.POP_VLAN_CODE).accept(new PopVlanActionDeserializer());
+        injector.apply(ActionConstants.PUSH_MPLS_CODE).accept(new PushMplsActionDeserializer());
+        injector.apply(ActionConstants.PUSH_PBB_CODE).accept(new PushPbbActionDeserializer());
+        injector.apply(ActionConstants.PUSH_VLAN_CODE).accept(new PushVlanActionDeserializer());
+        injector.apply(ActionConstants.SET_MPLS_TTL_CODE).accept(new SetMplsTtlActionDeserializer());
+        injector.apply(ActionConstants.SET_NW_TTL_CODE).accept(new SetNwTtlActionDeserializer());
+        injector.apply(ActionConstants.SET_QUEUE_CODE).accept(new SetQueueActionDeserializer());
+        injector.apply((byte) ActionConstants.SET_FIELD_CODE).accept(new SetFieldActionDeserializer());
     }
 
     /**
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/CopyTtlInActionDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/CopyTtlInActionDeserializer.java
new file mode 100644 (file)
index 0000000..3649f31
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.in._case.CopyTtlInBuilder;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+
+import io.netty.buffer.ByteBuf;
+
+public class CopyTtlInActionDeserializer extends AbstractActionDeserializer {
+
+    @Override
+    public Action deserialize(ByteBuf message) {
+        processHeader(message);
+        message.skipBytes(ActionConstants.PADDING_IN_ACTION_HEADER);
+
+        return new CopyTtlInCaseBuilder()
+            .setCopyTtlIn(new CopyTtlInBuilder().build())
+            .build();
+    }
+
+    @Override
+    public Action deserializeHeader(ByteBuf message) {
+        processHeader(message);
+        return new CopyTtlInCaseBuilder().build();
+    }
+
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/CopyTtlOutActionDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/CopyTtlOutActionDeserializer.java
new file mode 100644 (file)
index 0000000..38127d3
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
+
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.out._case.CopyTtlOutBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+
+import io.netty.buffer.ByteBuf;
+
+public class CopyTtlOutActionDeserializer extends AbstractActionDeserializer {
+
+    @Override
+    public Action deserialize(ByteBuf message) {
+        processHeader(message);
+        message.skipBytes(ActionConstants.PADDING_IN_ACTION_HEADER);
+
+        return new CopyTtlOutCaseBuilder()
+            .setCopyTtlOut(new CopyTtlOutBuilder().build())
+            .build();
+    }
+
+
+    @Override
+    public Action deserializeHeader(ByteBuf message) {
+        processHeader(message);
+        return new CopyTtlOutCaseBuilder().build();
+    }
+
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/DecMplsTtlActionDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/DecMplsTtlActionDeserializer.java
new file mode 100644 (file)
index 0000000..215a0ae
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
+
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.mpls.ttl._case.DecMplsTtlBuilder;
+
+import io.netty.buffer.ByteBuf;
+
+public class DecMplsTtlActionDeserializer extends AbstractActionDeserializer {
+
+    @Override
+    public Action deserialize(ByteBuf message) {
+        processHeader(message);
+        message.skipBytes(ActionConstants.PADDING_IN_ACTION_HEADER);
+
+        return new DecMplsTtlCaseBuilder()
+            .setDecMplsTtl(new DecMplsTtlBuilder().build())
+            .build();
+    }
+
+    @Override
+    public Action deserializeHeader(ByteBuf message) {
+        processHeader(message);
+        return new DecMplsTtlCaseBuilder().build();
+    }
+
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/DecNwTtlActionDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/DecNwTtlActionDeserializer.java
new file mode 100644 (file)
index 0000000..26319dd
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
+
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
+
+import io.netty.buffer.ByteBuf;
+
+public class DecNwTtlActionDeserializer extends AbstractActionDeserializer {
+
+    @Override
+    public Action deserialize(ByteBuf message) {
+        processHeader(message);
+        message.skipBytes(ActionConstants.PADDING_IN_ACTION_HEADER);
+
+        return new DecNwTtlCaseBuilder()
+            .setDecNwTtl(new DecNwTtlBuilder().build())
+            .build();
+    }
+
+    @Override
+    public Action deserializeHeader(ByteBuf message) {
+        processHeader(message);
+        return new DecNwTtlCaseBuilder().build();
+    }
+
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/GroupActionDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/GroupActionDeserializer.java
new file mode 100644 (file)
index 0000000..c5e1590
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder;
+
+import io.netty.buffer.ByteBuf;
+
+public class GroupActionDeserializer extends AbstractActionDeserializer {
+
+    @Override
+    public Action deserialize(ByteBuf message) {
+        processHeader(message);
+
+        return new GroupActionCaseBuilder()
+            .setGroupAction(new GroupActionBuilder()
+                    .setGroupId(message.readUnsignedInt())
+                    .build())
+            .build();
+    }
+
+    @Override
+    public Action deserializeHeader(ByteBuf message) {
+        processHeader(message);
+        return new GroupActionCaseBuilder().build();
+    }
+
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/OutputActionDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/OutputActionDeserializer.java
new file mode 100644 (file)
index 0000000..dc51a79
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
+
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
+
+import io.netty.buffer.ByteBuf;
+
+public class OutputActionDeserializer extends AbstractActionDeserializer {
+
+    @Override
+    public Action deserialize(ByteBuf message) {
+        processHeader(message);
+
+        final String portNumberAsString = OpenflowPortsUtil
+            .portNumberToString(OpenflowPortsUtil
+                    .getProtocolAgnosticPort(OpenflowVersion.OF13, message.readUnsignedInt()));
+
+        final int maxLength = message.readUnsignedShort();
+        message.skipBytes(ActionConstants.OUTPUT_PADDING);
+
+        return new OutputActionCaseBuilder()
+            .setOutputAction(new OutputActionBuilder()
+                    .setOutputNodeConnector(new Uri(portNumberAsString))
+                    .setMaxLength(maxLength)
+                    .build())
+            .build();
+    }
+
+    @Override
+    public Action deserializeHeader(ByteBuf message) {
+        processHeader(message);
+        return new OutputActionCaseBuilder().build();
+    }
+
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PopMplsActionDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PopMplsActionDeserializer.java
new file mode 100644 (file)
index 0000000..4c8c109
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
+
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder;
+
+import io.netty.buffer.ByteBuf;
+
+public class PopMplsActionDeserializer extends AbstractActionDeserializer {
+
+    @Override
+    public Action deserialize(ByteBuf message) {
+        processHeader(message);
+
+        final int ethType = message.readUnsignedShort();
+        message.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING);
+
+        return new PopMplsActionCaseBuilder()
+            .setPopMplsAction(new PopMplsActionBuilder()
+                    .setEthernetType(ethType)
+                    .build())
+            .build();
+    }
+
+    @Override
+    public Action deserializeHeader(ByteBuf message) {
+        processHeader(message);
+        return new PopMplsActionCaseBuilder().build();
+    }
+
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PopPbbActionDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PopPbbActionDeserializer.java
new file mode 100644 (file)
index 0000000..13915c2
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.pbb.action._case.PopPbbActionBuilder;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+
+import io.netty.buffer.ByteBuf;
+
+public class PopPbbActionDeserializer extends AbstractActionDeserializer {
+
+    @Override
+    public Action deserialize(ByteBuf message) {
+        processHeader(message);
+        message.skipBytes(ActionConstants.PADDING_IN_ACTION_HEADER);
+
+        return new PopPbbActionCaseBuilder()
+            .setPopPbbAction(new PopPbbActionBuilder().build())
+            .build();
+    }
+
+    @Override
+    public Action deserializeHeader(ByteBuf message) {
+        processHeader(message);
+        return new PopPbbActionCaseBuilder().build();
+    }
+
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PopVlanActionDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PopVlanActionDeserializer.java
new file mode 100644 (file)
index 0000000..c379912
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+
+import io.netty.buffer.ByteBuf;
+
+public class PopVlanActionDeserializer extends AbstractActionDeserializer {
+
+    @Override
+    public Action deserialize(ByteBuf message) {
+        processHeader(message);
+        message.skipBytes(ActionConstants.PADDING_IN_ACTION_HEADER);
+
+        return new PopVlanActionCaseBuilder()
+            .setPopVlanAction(new PopVlanActionBuilder().build())
+            .build();
+    }
+
+    @Override
+    public Action deserializeHeader(ByteBuf message) {
+        processHeader(message);
+        return new PopVlanActionCaseBuilder().build();
+    }
+
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PushMplsActionDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PushMplsActionDeserializer.java
new file mode 100644 (file)
index 0000000..99d434b
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+
+import io.netty.buffer.ByteBuf;
+
+public class PushMplsActionDeserializer extends AbstractActionDeserializer {
+
+    @Override
+    public Action deserialize(ByteBuf message) {
+        processHeader(message);
+        final int ethType = message.readUnsignedShort();
+        message.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING);
+
+        return new PushMplsActionCaseBuilder()
+            .setPushMplsAction(new PushMplsActionBuilder()
+                    .setEthernetType(ethType)
+                    .build())
+            .build();
+    }
+
+    @Override
+    public Action deserializeHeader(ByteBuf message) {
+        processHeader(message);
+        return new PushMplsActionCaseBuilder().build();
+    }
+
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PushPbbActionDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PushPbbActionDeserializer.java
new file mode 100644 (file)
index 0000000..19522a0
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+
+import io.netty.buffer.ByteBuf;
+
+public class PushPbbActionDeserializer extends AbstractActionDeserializer {
+
+    @Override
+    public Action deserialize(ByteBuf message) {
+        processHeader(message);
+        final int ethType = message.readUnsignedShort();
+        message.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING);
+
+        return new PushPbbActionCaseBuilder()
+            .setPushPbbAction(new PushPbbActionBuilder()
+                    .setEthernetType(ethType)
+                    .build())
+            .build();
+    }
+
+    @Override
+    public Action deserializeHeader(ByteBuf message) {
+        processHeader(message);
+        return new PushPbbActionCaseBuilder().build();
+    }
+
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PushVlanActionDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PushVlanActionDeserializer.java
new file mode 100644 (file)
index 0000000..4b73492
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+
+import io.netty.buffer.ByteBuf;
+
+public class PushVlanActionDeserializer extends AbstractActionDeserializer {
+
+    @Override
+    public Action deserialize(ByteBuf message) {
+        processHeader(message);
+        final int ethType = message.readUnsignedShort();
+        message.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING);
+
+        return new PushVlanActionCaseBuilder()
+            .setPushVlanAction(new PushVlanActionBuilder()
+                    .setEthernetType(ethType)
+                    .build())
+            .build();
+    }
+
+    @Override
+    public Action deserializeHeader(ByteBuf message) {
+        processHeader(message);
+        return new PushVlanActionCaseBuilder().build();
+    }
+
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/SetFieldActionDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/SetFieldActionDeserializer.java
new file mode 100644 (file)
index 0000000..0b2c894
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
+
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowplugin.api.openflow.protocol.deserialization.MatchEntryDeserializer;
+import org.opendaylight.openflowplugin.extension.api.path.MatchPath;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.key.MessageCodeMatchKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
+
+import io.netty.buffer.ByteBuf;
+
+public class SetFieldActionDeserializer extends AbstractActionDeserializer
+    implements DeserializerRegistryInjector {
+
+    private static final MessageCodeKey MATCH_KEY = new MessageCodeMatchKey(
+            EncodeConstants.OF13_VERSION_ID,
+            EncodeConstants.EMPTY_LENGTH,
+            Match.class,
+            MatchPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_MATCH);
+
+    private DeserializerRegistry registry;
+
+    @Override
+    public Action deserialize(ByteBuf message) {
+        final MatchEntryDeserializer deserializer = registry.getDeserializer(MATCH_KEY);
+        final MatchBuilder builder = new MatchBuilder();
+
+        final int startIndex = message.readerIndex();
+        processHeader(message);
+        deserializer.deserializeEntry(message, builder);
+
+        int paddingRemainder = (message.readerIndex() - startIndex) % EncodeConstants.PADDING;
+        if (paddingRemainder != 0) {
+            message.skipBytes(EncodeConstants.PADDING - paddingRemainder);
+        }
+
+        return new SetFieldCaseBuilder()
+            .setSetField(new SetFieldBuilder(builder.build()).build())
+            .build();
+    }
+
+    @Override
+    public Action deserializeHeader(ByteBuf message) {
+        processHeader(message);
+        return new SetFieldCaseBuilder().build();
+    }
+
+    @Override
+    public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) {
+        registry = deserializerRegistry;
+    }
+
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/SetMplsTtlActionDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/SetMplsTtlActionDeserializer.java
new file mode 100644 (file)
index 0000000..b4b0e71
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlActionBuilder;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+
+import io.netty.buffer.ByteBuf;
+
+public class SetMplsTtlActionDeserializer extends AbstractActionDeserializer {
+
+    @Override
+    public Action deserialize(ByteBuf message) {
+        processHeader(message);
+        final short mplsTtl = message.readUnsignedByte();
+        message.skipBytes(ActionConstants.SET_MPLS_TTL_PADDING);
+
+        return new SetMplsTtlActionCaseBuilder()
+            .setSetMplsTtlAction(new SetMplsTtlActionBuilder()
+                    .setMplsTtl(mplsTtl)
+                    .build())
+            .build();
+    }
+
+    @Override
+    public Action deserializeHeader(ByteBuf message) {
+        processHeader(message);
+        return new SetMplsTtlActionCaseBuilder().build();
+    }
+
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/SetNwTtlActionDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/SetNwTtlActionDeserializer.java
new file mode 100644 (file)
index 0000000..8956e2c
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.ttl.action._case.SetNwTtlActionBuilder;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+
+import io.netty.buffer.ByteBuf;
+
+public class SetNwTtlActionDeserializer extends AbstractActionDeserializer {
+
+    @Override
+    public Action deserialize(ByteBuf message) {
+        processHeader(message);
+        final short nwTtl = message.readUnsignedByte();
+        message.skipBytes(ActionConstants.SET_NW_TTL_PADDING);
+
+        return new SetNwTtlActionCaseBuilder()
+            .setSetNwTtlAction(new SetNwTtlActionBuilder()
+                    .setNwTtl(nwTtl)
+                    .build())
+            .build();
+    }
+
+    @Override
+    public Action deserializeHeader(ByteBuf message) {
+        processHeader(message);
+        return new SetNwTtlActionCaseBuilder().build();
+    }
+
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/SetQueueActionDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/SetQueueActionDeserializer.java
new file mode 100644 (file)
index 0000000..25a55e3
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueActionBuilder;
+
+import io.netty.buffer.ByteBuf;
+
+public class SetQueueActionDeserializer extends AbstractActionDeserializer {
+
+    @Override
+    public Action deserialize(ByteBuf message) {
+        processHeader(message);
+        final long queueId = message.readUnsignedInt();
+
+        return new SetQueueActionCaseBuilder()
+            .setSetQueueAction(new SetQueueActionBuilder()
+                    .setQueueId(queueId)
+                    .build())
+            .build();
+    }
+
+    @Override
+    public Action deserializeHeader(ByteBuf message) {
+        processHeader(message);
+        return new SetQueueActionCaseBuilder().build();
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/CopyTtlInActionDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/CopyTtlInActionDeserializerTest.java
new file mode 100644 (file)
index 0000000..395559d
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCase;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class CopyTtlInActionDeserializerTest extends AbstractActionDeserializerTest {
+
+    @Test
+    public void testDeserialize() throws Exception {
+        final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+        writeHeader(in);
+        in.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER);
+
+        final Action action = deserializeAction(in);
+        assertTrue(CopyTtlInCase.class.isInstance(action));
+        assertEquals(0, in.readableBytes());
+    }
+
+    @Override
+    protected short getType() {
+        return ActionConstants.COPY_TTL_IN_CODE;
+    }
+
+    @Override
+    protected short getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/CopyTtlOutActionDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/CopyTtlOutActionDeserializerTest.java
new file mode 100644 (file)
index 0000000..71d1e13
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCase;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class CopyTtlOutActionDeserializerTest extends AbstractActionDeserializerTest {
+
+    @Test
+    public void testDeserialize() throws Exception {
+        final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+        writeHeader(in);
+        in.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER);
+
+        final Action action = deserializeAction(in);
+        assertTrue(CopyTtlOutCase.class.isInstance(action));
+        assertEquals(0, in.readableBytes());
+    }
+
+    @Override
+    protected short getType() {
+        return ActionConstants.COPY_TTL_OUT_CODE;
+    }
+
+    @Override
+    protected short getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/DecMplsTtlActionDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/DecMplsTtlActionDeserializerTest.java
new file mode 100644 (file)
index 0000000..5282be0
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCase;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class DecMplsTtlActionDeserializerTest extends AbstractActionDeserializerTest {
+
+    @Test
+    public void testDeserialize() throws Exception {
+        final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+        writeHeader(in);
+        in.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER);
+
+        final Action action = deserializeAction(in);
+        assertTrue(DecMplsTtlCase.class.isInstance(action));
+        assertEquals(0, in.readableBytes());
+    }
+
+    @Override
+    protected short getType() {
+        return ActionConstants.DEC_MPLS_TTL_CODE;
+    }
+
+    @Override
+    protected short getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/DecNwTtlActionDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/DecNwTtlActionDeserializerTest.java
new file mode 100644 (file)
index 0000000..dacaf00
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCase;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class DecNwTtlActionDeserializerTest extends AbstractActionDeserializerTest {
+
+    @Test
+    public void testDeserialize() throws Exception {
+        final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+        writeHeader(in);
+        in.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER);
+
+        final Action action = deserializeAction(in);
+        assertTrue(DecNwTtlCase.class.isInstance(action));
+        assertEquals(0, in.readableBytes());
+    }
+
+    @Override
+    protected short getType() {
+        return ActionConstants.DEC_NW_TTL_CODE;
+    }
+
+    @Override
+    protected short getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/GroupActionDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/GroupActionDeserializerTest.java
new file mode 100644 (file)
index 0000000..5282cff
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class GroupActionDeserializerTest extends AbstractActionDeserializerTest {
+
+    @Test
+    public void testDeserialize() throws Exception {
+        final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+        final int groupId = 10;
+        writeHeader(in);
+        in.writeInt(groupId);
+
+        final Action action = deserializeAction(in);
+        assertTrue(GroupActionCase.class.isInstance(action));
+        assertEquals(groupId, GroupActionCase.class.cast(action).getGroupAction().getGroupId().intValue());
+        assertEquals(0, in.readableBytes());
+    }
+
+    @Override
+    protected short getType() {
+        return ActionConstants.GROUP_CODE;
+    }
+
+    @Override
+    protected short getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/OutputActionDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/OutputActionDeserializerTest.java
new file mode 100644 (file)
index 0000000..f20cfa2
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputAction;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class OutputActionDeserializerTest extends AbstractActionDeserializerTest {
+
+    @Test
+    public void testDeserialize() throws Exception {
+        final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+        final int portNum = 10;
+        final short maxLength = 24;
+        writeHeader(in);
+        in.writeInt(portNum);
+        in.writeShort(maxLength);
+        in.writeZero(ActionConstants.OUTPUT_PADDING);
+
+        final Action action = deserializeAction(in);
+        assertTrue(OutputActionCase.class.isInstance(action));
+
+        final OutputAction outputAction = OutputActionCase.class.cast(action).getOutputAction();
+        assertEquals(portNum, InventoryDataServiceUtil.portNumberfromNodeConnectorId(
+                    OpenflowVersion.OF13, outputAction.getOutputNodeConnector().getValue()).intValue());
+        assertEquals(maxLength, outputAction.getMaxLength().shortValue());
+        assertEquals(0, in.readableBytes());
+    }
+
+    @Override
+    protected short getType() {
+        return ActionConstants.OUTPUT_CODE;
+    }
+
+    @Override
+    protected short getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PopMplsActionDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PopMplsActionDeserializerTest.java
new file mode 100644 (file)
index 0000000..ca5287d
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsAction;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class PopMplsActionDeserializerTest extends AbstractActionDeserializerTest {
+
+    @Test
+    public void testDeserialize() throws Exception {
+        final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+        final short ethType = 10;
+        writeHeader(in);
+        in.writeShort(ethType);
+        in.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING);
+
+        final Action action = deserializeAction(in);
+        assertTrue(PopMplsActionCase.class.isInstance(action));
+
+        final PopMplsAction popAction = PopMplsActionCase.class.cast(action).getPopMplsAction();
+        assertEquals(ethType, popAction.getEthernetType().shortValue());
+        assertEquals(0, in.readableBytes());
+    }
+
+    @Override
+    protected short getType() {
+        return ActionConstants.POP_MPLS_CODE;
+    }
+
+    @Override
+    protected short getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PopPbbActionDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PopPbbActionDeserializerTest.java
new file mode 100644 (file)
index 0000000..40ee875
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCase;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class PopPbbActionDeserializerTest extends AbstractActionDeserializerTest {
+
+    @Test
+    public void testDeserialize() throws Exception {
+        final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+        writeHeader(in);
+        in.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER);
+
+        final Action action = deserializeAction(in);
+        assertTrue(PopPbbActionCase.class.isInstance(action));
+        assertEquals(0, in.readableBytes());
+    }
+
+    @Override
+    protected short getType() {
+        return ActionConstants.POP_PBB_CODE;
+    }
+
+    @Override
+    protected short getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PopVlanActionDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PopVlanActionDeserializerTest.java
new file mode 100644 (file)
index 0000000..5bd30db
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCase;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class PopVlanActionDeserializerTest extends AbstractActionDeserializerTest {
+
+    @Test
+    public void testDeserialize() throws Exception {
+        final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+        writeHeader(in);
+        in.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER);
+
+        final Action action = deserializeAction(in);
+        assertTrue(PopVlanActionCase.class.isInstance(action));
+        assertEquals(0, in.readableBytes());
+    }
+
+    @Override
+    protected short getType() {
+        return ActionConstants.POP_VLAN_CODE;
+    }
+
+    @Override
+    protected short getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PushMplsActionDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PushMplsActionDeserializerTest.java
new file mode 100644 (file)
index 0000000..5e075af
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCase;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class PushMplsActionDeserializerTest extends AbstractActionDeserializerTest {
+
+    @Test
+    public void testDeserialize() throws Exception {
+        final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+        final short ethType = 10;
+        writeHeader(in);
+        in.writeShort(ethType);
+        in.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING);
+
+        final Action action = deserializeAction(in);
+        assertTrue(PushMplsActionCase.class.isInstance(action));
+        assertEquals(ethType, PushMplsActionCase.class.cast(action).getPushMplsAction().getEthernetType().shortValue());
+        assertEquals(0, in.readableBytes());
+    }
+
+    @Override
+    protected short getType() {
+        return ActionConstants.PUSH_MPLS_CODE;
+    }
+
+    @Override
+    protected short getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PushPbbActionDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PushPbbActionDeserializerTest.java
new file mode 100644 (file)
index 0000000..97b36f5
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCase;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class PushPbbActionDeserializerTest extends AbstractActionDeserializerTest {
+
+    @Test
+    public void testDeserialize() throws Exception {
+        final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+        final short ethType = 10;
+        writeHeader(in);
+        in.writeShort(ethType);
+        in.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING);
+
+        final Action action = deserializeAction(in);
+        assertTrue(PushPbbActionCase.class.isInstance(action));
+        assertEquals(ethType, PushPbbActionCase.class.cast(action).getPushPbbAction().getEthernetType().shortValue());
+        assertEquals(0, in.readableBytes());
+    }
+
+    @Override
+    protected short getType() {
+        return ActionConstants.PUSH_PBB_CODE;
+    }
+
+    @Override
+    protected short getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PushVlanActionDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/PushVlanActionDeserializerTest.java
new file mode 100644 (file)
index 0000000..7c5e65d
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class PushVlanActionDeserializerTest extends AbstractActionDeserializerTest {
+
+    @Test
+    public void testDeserialize() throws Exception {
+        final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+        final short ethType = 10;
+        writeHeader(in);
+        in.writeShort(ethType);
+        in.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING);
+
+        final Action action = deserializeAction(in);
+        assertTrue(PushVlanActionCase.class.isInstance(action));
+        assertEquals(ethType, PushVlanActionCase.class.cast(action).getPushVlanAction().getEthernetType().shortValue());
+        assertEquals(0, in.readableBytes());
+    }
+
+    @Override
+    protected short getType() {
+        return ActionConstants.PUSH_VLAN_CODE;
+    }
+
+    @Override
+    protected short getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/SetFieldActionDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/SetFieldActionDeserializerTest.java
new file mode 100644 (file)
index 0000000..4155c95
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.BinContent;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class SetFieldActionDeserializerTest extends AbstractActionDeserializerTest {
+
+    @Test
+    public void testDeserialize() throws Exception {
+        final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+        final int portNum = 0xfffffffa;
+        writeHeader(in);
+        in.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
+        in.writeByte(OxmMatchConstants.IN_PORT << 1);
+        in.writeByte(EncodeConstants.SIZE_OF_INT_IN_BYTES);
+        in.writeInt(portNum);
+        in.writeZero(EncodeConstants.SIZE_OF_INT_IN_BYTES);
+
+        final Action action = deserializeAction(in);
+        assertTrue(SetFieldCase.class.isInstance(action));
+        assertEquals(
+                OpenflowPortsUtil.getPortLogicalName(EncodeConstants.OF13_VERSION_ID, BinContent.intToUnsignedLong(portNum)),
+                SetFieldCase.class.cast(action).getSetField().getInPort().getValue());
+        assertEquals(0, in.readableBytes());
+    }
+
+    @Override
+    protected short getType() {
+        return ActionConstants.SET_FIELD_CODE;
+    }
+
+    @Override
+    protected short getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/SetMplsTtlActionDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/SetMplsTtlActionDeserializerTest.java
new file mode 100644 (file)
index 0000000..2b4dfa6
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCase;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class SetMplsTtlActionDeserializerTest extends AbstractActionDeserializerTest {
+
+    @Test
+    public void testDeserialize() throws Exception {
+        final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+        final short mplsTtl = 10;
+        writeHeader(in);
+        in.writeByte(mplsTtl);
+        in.writeZero(ActionConstants.SET_MPLS_TTL_PADDING);
+
+        final Action action = deserializeAction(in);
+        assertTrue(SetMplsTtlActionCase.class.isInstance(action));
+        assertEquals(mplsTtl, SetMplsTtlActionCase.class.cast(action).getSetMplsTtlAction().getMplsTtl().shortValue());
+        assertEquals(0, in.readableBytes());
+    }
+
+    @Override
+    protected short getType() {
+        return ActionConstants.SET_MPLS_TTL_CODE;
+    }
+
+    @Override
+    protected short getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/SetNwTtlActionDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/SetNwTtlActionDeserializerTest.java
new file mode 100644 (file)
index 0000000..95138ea
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCase;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class SetNwTtlActionDeserializerTest extends AbstractActionDeserializerTest {
+
+    @Test
+    public void testDeserialize() throws Exception {
+        final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+        final short nwTtl = 10;
+        writeHeader(in);
+        in.writeByte(nwTtl);
+        in.writeZero(ActionConstants.SET_NW_TTL_PADDING);
+
+        final Action action = deserializeAction(in);
+        assertTrue(SetNwTtlActionCase.class.isInstance(action));
+        assertEquals(nwTtl, SetNwTtlActionCase.class.cast(action).getSetNwTtlAction().getNwTtl().shortValue());
+        assertEquals(0, in.readableBytes());
+    }
+
+    @Override
+    protected short getType() {
+        return ActionConstants.SET_NW_TTL_CODE;
+    }
+
+    @Override
+    protected short getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/SetQueueActionDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/SetQueueActionDeserializerTest.java
new file mode 100644 (file)
index 0000000..5fe9c88
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCase;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class SetQueueActionDeserializerTest extends AbstractActionDeserializerTest {
+
+    @Test
+    public void testDeserialize() throws Exception {
+        final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+        final int queueId = 10;
+        writeHeader(in);
+        in.writeInt(queueId);
+
+        final Action action = deserializeAction(in);
+        assertTrue(SetQueueActionCase.class.isInstance(action));
+        assertEquals(queueId, SetQueueActionCase.class.cast(action).getSetQueueAction().getQueueId().intValue());
+        assertEquals(0, in.readableBytes());
+    }
+
+    @Override
+    protected short getType() {
+        return ActionConstants.SET_QUEUE_CODE;
+    }
+
+    @Override
+    protected short getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+}