Add Action serializers 40/48540/21
authorTomas Slusny <tomas.slusny@pantheon.tech>
Mon, 21 Nov 2016 12:59:54 +0000 (13:59 +0100)
committerTomas Slusny <tomas.slusny@pantheon.tech>
Wed, 14 Dec 2016 17:11:47 +0000 (17:11 +0000)
Inject action serializers into OFJ. These serializers will serialize
these actions to raw bytes:

  - CopyTtlIn
  - CopyTtlOut
  - DecMplsTtl
  - DecNwTtl
  - GroupAction
  - OutputAction
  - PopMplsAction
  - PopPbbAction
  - PopVlanAction
  - PushMplsAction
  - PushPbbAction
  - PushVlanAction
  - SetMplsTtlAction
  - SetNwTtlAction
  - SetQueueAction
  - SetFieldAction
  - DropAction
  - SetVlanIdAction
  - SetVlanPcpAction
  - StripVlanAction
  - SetDlSrcAction
  - SetDlDstAction
  - SetNwSrcAction
  - SetNwDstAction
  - SetTpSrcAction
  - SetTpDstAction
  - SetNwTosAction

See also: bug 7138

Change-Id: I5b42b0b2d2afd3468768e28bd11bfdcfcbbbc142
Signed-off-by: Tomas Slusny <tomas.slusny@pantheon.tech>
54 files changed:
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/ActionSerializerInjector.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/AbstractSetFieldActionSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/CopyTtlInActionSerializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/CopyTtlOutActionSerializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/DecMplsTtlActionSerializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/DecNwTtlActionSerializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/DropActionSerializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/GroupActionSerializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/OutputActionSerializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PopMplsActionSerializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PopPbbActionSerializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PopVlanActionSerializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushMplsActionSerializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushPbbActionSerializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushVlanActionSerializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetDlDstActionSerializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetDlSrcActionSerializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetFieldActionSerializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetMplsTtlActionSerializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwDstActionSerializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwSrcActionSerializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwTosActionSerializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwTtlActionSerializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetQueueActionSerializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpDstActionSerializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpSrcActionSerializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetVlanIdActionSerializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetVlanPcpActionSerializer.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/StripVlanActionSerializer.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/CopyTtlInActionSerializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/CopyTtlOutActionSerializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/DecMplsTtlActionSerializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/DecNwTtlActionSerializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/GroupActionSerializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/OutputActionSerializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PopMplsActionSerializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PopPbbActionSerializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PopVlanActionSerializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushMplsActionSerializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushPbbActionSerializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushVlanActionSerializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetDlDstActionSerializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetDlSrcActionSerializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetMplsTtlActionSerializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwDstActionSerializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwSrcActionSerializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwTosActionSerializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwTtlActionSerializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetQueueActionSerializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpDstActionSerializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpSrcActionSerializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetVlanIdActionSerializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetVlanPcpActionSerializerTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/StripVlanActionSerializerTest.java [new file with mode: 0644]

index b0d5d52a9c0d780f0b44120ba3f760391473625d..08cfcaaf160af1070a8f5fc98c6f946ff35996f4 100644 (file)
@@ -15,7 +15,61 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerExtensionProvider;
 import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowplugin.impl.protocol.serialization.actions.CopyTtlInActionSerializer;
+import org.opendaylight.openflowplugin.impl.protocol.serialization.actions.CopyTtlOutActionSerializer;
+import org.opendaylight.openflowplugin.impl.protocol.serialization.actions.DecMplsTtlActionSerializer;
+import org.opendaylight.openflowplugin.impl.protocol.serialization.actions.DecNwTtlActionSerializer;
+import org.opendaylight.openflowplugin.impl.protocol.serialization.actions.DropActionSerializer;
+import org.opendaylight.openflowplugin.impl.protocol.serialization.actions.GroupActionSerializer;
+import org.opendaylight.openflowplugin.impl.protocol.serialization.actions.OutputActionSerializer;
+import org.opendaylight.openflowplugin.impl.protocol.serialization.actions.PopMplsActionSerializer;
+import org.opendaylight.openflowplugin.impl.protocol.serialization.actions.PopPbbActionSerializer;
+import org.opendaylight.openflowplugin.impl.protocol.serialization.actions.PopVlanActionSerializer;
+import org.opendaylight.openflowplugin.impl.protocol.serialization.actions.PushMplsActionSerializer;
+import org.opendaylight.openflowplugin.impl.protocol.serialization.actions.PushPbbActionSerializer;
+import org.opendaylight.openflowplugin.impl.protocol.serialization.actions.PushVlanActionSerializer;
+import org.opendaylight.openflowplugin.impl.protocol.serialization.actions.SetDlDstActionSerializer;
+import org.opendaylight.openflowplugin.impl.protocol.serialization.actions.SetDlSrcActionSerializer;
+import org.opendaylight.openflowplugin.impl.protocol.serialization.actions.SetFieldActionSerializer;
+import org.opendaylight.openflowplugin.impl.protocol.serialization.actions.SetMplsTtlActionSerializer;
+import org.opendaylight.openflowplugin.impl.protocol.serialization.actions.SetNwDstActionSerializer;
+import org.opendaylight.openflowplugin.impl.protocol.serialization.actions.SetNwSrcActionSerializer;
+import org.opendaylight.openflowplugin.impl.protocol.serialization.actions.SetNwTosActionSerializer;
+import org.opendaylight.openflowplugin.impl.protocol.serialization.actions.SetNwTtlActionSerializer;
+import org.opendaylight.openflowplugin.impl.protocol.serialization.actions.SetQueueActionSerializer;
+import org.opendaylight.openflowplugin.impl.protocol.serialization.actions.SetTpDstActionSerializer;
+import org.opendaylight.openflowplugin.impl.protocol.serialization.actions.SetTpSrcActionSerializer;
+import org.opendaylight.openflowplugin.impl.protocol.serialization.actions.SetVlanIdActionSerializer;
+import org.opendaylight.openflowplugin.impl.protocol.serialization.actions.SetVlanPcpActionSerializer;
+import org.opendaylight.openflowplugin.impl.protocol.serialization.actions.StripVlanActionSerializer;
 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 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase;
+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.PopMplsActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.StripVlanActionCase;
 
 /**
  * Util class for injecting new action serializers into OpenflowJava
@@ -30,6 +84,34 @@ class ActionSerializerInjector {
         // Inject new action serializers here using injector created by createInjector method
         final Function<Class<? extends Action>, Consumer<OFSerializer<? extends Action>>> injector =
                 createInjector(provider, EncodeConstants.OF13_VERSION_ID);
+
+        injector.apply(SetFieldCase.class).accept(new SetFieldActionSerializer());
+        injector.apply(CopyTtlInCase.class).accept(new CopyTtlInActionSerializer());
+        injector.apply(CopyTtlOutCase.class).accept(new CopyTtlOutActionSerializer());
+        injector.apply(DecMplsTtlCase.class).accept(new DecMplsTtlActionSerializer());
+        injector.apply(DecNwTtlCase.class).accept(new DecNwTtlActionSerializer());
+        injector.apply(GroupActionCase.class).accept(new GroupActionSerializer());
+        injector.apply(OutputActionCase.class).accept(new OutputActionSerializer());
+        injector.apply(PopMplsActionCase.class).accept(new PopMplsActionSerializer());
+        injector.apply(PopPbbActionCase.class).accept(new PopPbbActionSerializer());
+        injector.apply(PopVlanActionCase.class).accept(new PopVlanActionSerializer());
+        injector.apply(PushMplsActionCase.class).accept(new PushMplsActionSerializer());
+        injector.apply(PushPbbActionCase.class).accept(new PushPbbActionSerializer());
+        injector.apply(PushVlanActionCase.class).accept(new PushVlanActionSerializer());
+        injector.apply(SetMplsTtlActionCase.class).accept(new SetMplsTtlActionSerializer());
+        injector.apply(SetNwTtlActionCase.class).accept(new SetNwTtlActionSerializer());
+        injector.apply(SetQueueActionCase.class).accept(new SetQueueActionSerializer());
+        injector.apply(DropActionCase.class).accept(new DropActionSerializer());
+        injector.apply(SetVlanIdActionCase.class).accept(new SetVlanIdActionSerializer());
+        injector.apply(SetVlanPcpActionCase.class).accept(new SetVlanPcpActionSerializer());
+        injector.apply(StripVlanActionCase.class).accept(new StripVlanActionSerializer());
+        injector.apply(SetDlSrcActionCase.class).accept(new SetDlSrcActionSerializer());
+        injector.apply(SetDlDstActionCase.class).accept(new SetDlDstActionSerializer());
+        injector.apply(SetNwSrcActionCase.class).accept(new SetNwSrcActionSerializer());
+        injector.apply(SetNwDstActionCase.class).accept(new SetNwDstActionSerializer());
+        injector.apply(SetTpSrcActionCase.class).accept(new SetTpSrcActionSerializer());
+        injector.apply(SetTpDstActionCase.class).accept(new SetTpDstActionSerializer());
+        injector.apply(SetNwTosActionCase.class).accept(new SetNwTosActionSerializer());
     }
 
     /**
@@ -47,4 +129,4 @@ class ActionSerializerInjector {
                         new MessageTypeKey<>(version, type),
                         serializer);
     }
-}
\ No newline at end of file
+}
index 06289bda0ca2c5af5dda6b41778cf031ae9ee60c..17cdd527a0f8146d2f0410759c2070ae46eedbc3 100644 (file)
@@ -17,7 +17,6 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 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.SetFieldCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldAction;
 
 public abstract class AbstractSetFieldActionSerializer extends AbstractActionSerializer implements SerializerRegistryInjector {
 
@@ -26,7 +25,7 @@ public abstract class AbstractSetFieldActionSerializer extends AbstractActionSer
      @Override
      public void serialize(Action input, ByteBuf outBuffer) {
           final OFSerializer<Action> serializer = registry
-                .getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, SetFieldAction.class));
+                .getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, SetFieldCase.class));
 
           serializer.serialize(buildAction(input), outBuffer);
      }
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/CopyTtlInActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/CopyTtlInActionSerializer.java
new file mode 100644 (file)
index 0000000..9ea760c
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * 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.serialization.actions;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+
+public class CopyTtlInActionSerializer extends AbstractActionSerializer {
+    @Override
+    public void serialize(Action action, ByteBuf outBuffer) {
+        super.serialize(action, outBuffer);
+        outBuffer.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER);
+    }
+
+    @Override
+    protected int getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+    @Override
+    protected int getType() {
+        return ActionConstants.COPY_TTL_IN_CODE;
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/CopyTtlOutActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/CopyTtlOutActionSerializer.java
new file mode 100644 (file)
index 0000000..c9114d2
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * 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.serialization.actions;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+
+public class CopyTtlOutActionSerializer extends AbstractActionSerializer {
+    @Override
+    public void serialize(Action action, ByteBuf outBuffer) {
+        super.serialize(action, outBuffer);
+        outBuffer.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER);
+    }
+
+    @Override
+    protected int getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+    @Override
+    protected int getType() {
+        return ActionConstants.COPY_TTL_OUT_CODE;
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/DecMplsTtlActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/DecMplsTtlActionSerializer.java
new file mode 100644 (file)
index 0000000..fb62421
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * 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.serialization.actions;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+
+public class DecMplsTtlActionSerializer extends AbstractActionSerializer {
+    @Override
+    public void serialize(Action action, ByteBuf outBuffer) {
+        super.serialize(action, outBuffer);
+        outBuffer.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER);
+    }
+
+    @Override
+    protected int getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+    @Override
+    protected int getType() {
+        return ActionConstants.DEC_MPLS_TTL_CODE;
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/DecNwTtlActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/DecNwTtlActionSerializer.java
new file mode 100644 (file)
index 0000000..e758ab1
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * 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.serialization.actions;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+
+public class DecNwTtlActionSerializer extends AbstractActionSerializer {
+    @Override
+    public void serialize(Action action, ByteBuf outBuffer) {
+        super.serialize(action, outBuffer);
+        outBuffer.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER);
+    }
+
+    @Override
+    protected int getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+    @Override
+    protected int getType() {
+        return ActionConstants.DEC_NW_TTL_CODE;
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/DropActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/DropActionSerializer.java
new file mode 100644 (file)
index 0000000..22d3e71
--- /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.serialization.actions;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+
+public class DropActionSerializer extends AbstractActionSerializer {
+
+    @Override
+    public void serialize(Action action, ByteBuf outBuffer) {
+        // NOOP
+    }
+
+    @Override
+    public void serializeHeader(Action action, ByteBuf outBuffer) {
+        // NOOP
+    }
+
+    @Override
+    protected int getLength() {
+        return 0;
+    }
+
+    @Override
+    protected int getType() {
+        return 0;
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/GroupActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/GroupActionSerializer.java
new file mode 100644 (file)
index 0000000..e52f2af
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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.serialization.actions;
+
+import io.netty.buffer.ByteBuf;
+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 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupAction;
+
+public class GroupActionSerializer extends AbstractActionSerializer {
+    @Override
+    public void serialize(Action action, ByteBuf outBuffer) {
+        super.serialize(action, outBuffer);
+        final GroupAction groupAction = GroupActionCase.class.cast(action).getGroupAction();
+        outBuffer.writeInt(groupAction.getGroupId().intValue());
+    }
+
+    @Override
+    protected int getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+    @Override
+    protected int getType() {
+        return ActionConstants.GROUP_CODE;
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/OutputActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/OutputActionSerializer.java
new file mode 100644 (file)
index 0000000..8c8caba
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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.serialization.actions;
+
+import io.netty.buffer.ByteBuf;
+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;
+
+public class OutputActionSerializer extends AbstractActionSerializer {
+    @Override
+    public void serialize(Action action, ByteBuf outBuffer) {
+        super.serialize(action, outBuffer);
+        final OutputAction outputAction = OutputActionCase.class.cast(action).getOutputAction();
+        outBuffer.writeInt(InventoryDataServiceUtil.portNumberfromNodeConnectorId(
+                OpenflowVersion.OF13,
+                outputAction.getOutputNodeConnector().getValue()).intValue());
+        outBuffer.writeShort(outputAction.getMaxLength());
+        outBuffer.writeZero(ActionConstants.OUTPUT_PADDING);
+    }
+
+    @Override
+    protected int getLength() {
+        return ActionConstants.LARGER_ACTION_LENGTH;
+    }
+
+    @Override
+    protected int getType() {
+        return ActionConstants.OUTPUT_CODE;
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PopMplsActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PopMplsActionSerializer.java
new file mode 100644 (file)
index 0000000..952e077
--- /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.serialization.actions;
+
+import io.netty.buffer.ByteBuf;
+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;
+
+public class PopMplsActionSerializer extends AbstractActionSerializer {
+    @Override
+    public void serialize(Action action, ByteBuf outBuffer) {
+        super.serialize(action, outBuffer);
+        final PopMplsAction popMplsAction = PopMplsActionCase.class.cast(action).getPopMplsAction();
+        outBuffer.writeShort(popMplsAction.getEthernetType());
+        outBuffer.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING);
+    }
+
+    @Override
+    protected int getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+    @Override
+    protected int getType() {
+        return ActionConstants.POP_MPLS_CODE;
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PopPbbActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PopPbbActionSerializer.java
new file mode 100644 (file)
index 0000000..5142dc6
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * 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.serialization.actions;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+
+public class PopPbbActionSerializer extends AbstractActionSerializer {
+    @Override
+    public void serialize(Action action, ByteBuf outBuffer) {
+        super.serialize(action, outBuffer);
+        outBuffer.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER);
+    }
+
+    @Override
+    protected int getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+    @Override
+    protected int getType() {
+        return ActionConstants.POP_PBB_CODE;
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PopVlanActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PopVlanActionSerializer.java
new file mode 100644 (file)
index 0000000..87f5a56
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * 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.serialization.actions;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+
+public class PopVlanActionSerializer extends AbstractActionSerializer {
+    @Override
+    public void serialize(Action action, ByteBuf outBuffer) {
+        super.serialize(action, outBuffer);
+        outBuffer.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER);
+    }
+
+    @Override
+    protected int getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+    @Override
+    protected int getType() {
+        return ActionConstants.POP_VLAN_CODE;
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushMplsActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushMplsActionSerializer.java
new file mode 100644 (file)
index 0000000..84baee8
--- /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.serialization.actions;
+
+import io.netty.buffer.ByteBuf;
+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 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsAction;
+
+public class PushMplsActionSerializer extends AbstractActionSerializer {
+    @Override
+    public void serialize(Action action, ByteBuf outBuffer) {
+        super.serialize(action, outBuffer);
+        final PushMplsAction pushMplsAction = PushMplsActionCase.class.cast(action).getPushMplsAction();
+        outBuffer.writeShort(pushMplsAction.getEthernetType());
+        outBuffer.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING);
+    }
+
+    @Override
+    protected int getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+    @Override
+    protected int getType() {
+        return ActionConstants.PUSH_MPLS_CODE;
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushPbbActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushPbbActionSerializer.java
new file mode 100644 (file)
index 0000000..9c04c9b
--- /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.serialization.actions;
+
+import io.netty.buffer.ByteBuf;
+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 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbAction;
+
+public class PushPbbActionSerializer extends AbstractActionSerializer {
+    @Override
+    public void serialize(Action action, ByteBuf outBuffer) {
+        super.serialize(action, outBuffer);
+        final PushPbbAction pushPbbAction = PushPbbActionCase.class.cast(action).getPushPbbAction();
+        outBuffer.writeShort(pushPbbAction.getEthernetType());
+        outBuffer.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING);
+    }
+
+    @Override
+    protected int getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+    @Override
+    protected int getType() {
+        return ActionConstants.PUSH_PBB_CODE;
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushVlanActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushVlanActionSerializer.java
new file mode 100644 (file)
index 0000000..4318fcd
--- /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.serialization.actions;
+
+import io.netty.buffer.ByteBuf;
+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 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanAction;
+
+public class PushVlanActionSerializer extends AbstractActionSerializer {
+    @Override
+    public void serialize(Action action, ByteBuf outBuffer) {
+        super.serialize(action, outBuffer);
+        final PushVlanAction pushVlanAction = PushVlanActionCase.class.cast(action).getPushVlanAction();
+        outBuffer.writeShort(pushVlanAction.getEthernetType());
+        outBuffer.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING);
+    }
+
+    @Override
+    protected int getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+    @Override
+    protected int getType() {
+        return ActionConstants.PUSH_VLAN_CODE;
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetDlDstActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetDlDstActionSerializer.java
new file mode 100644 (file)
index 0000000..471118b
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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.serialization.actions;
+
+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.SetDlDstActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase;
+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.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
+
+public class SetDlDstActionSerializer extends AbstractSetFieldActionSerializer {
+
+    @Override
+    protected SetFieldCase buildAction(Action input) {
+        return new SetFieldCaseBuilder()
+                .setSetField(new SetFieldBuilder()
+                        .setEthernetMatch(new EthernetMatchBuilder()
+                                .setEthernetDestination(new EthernetDestinationBuilder()
+                                        .setAddress(SetDlDstActionCase.class.cast(input).getSetDlDstAction().getAddress())
+                                        .build())
+                                .build())
+                        .build())
+                .build();
+    }
+
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetDlSrcActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetDlSrcActionSerializer.java
new file mode 100644 (file)
index 0000000..b2431f9
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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.serialization.actions;
+
+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.SetDlSrcActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase;
+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.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
+
+public class SetDlSrcActionSerializer extends AbstractSetFieldActionSerializer {
+
+    @Override
+    protected SetFieldCase buildAction(Action input) {
+        return new SetFieldCaseBuilder()
+                .setSetField(new SetFieldBuilder()
+                        .setEthernetMatch(new EthernetMatchBuilder()
+                                .setEthernetSource(new EthernetSourceBuilder()
+                                        .setAddress(SetDlSrcActionCase.class.cast(input).getSetDlSrcAction().getAddress())
+                                        .build())
+                                .build())
+                        .build())
+                .build();
+    }
+
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetFieldActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetFieldActionSerializer.java
new file mode 100644 (file)
index 0000000..297e200
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * 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.serialization.actions;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+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.SetFieldCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetField;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
+
+public class SetFieldActionSerializer extends AbstractActionSerializer implements SerializerRegistryInjector {
+    private SerializerRegistry registry;
+
+    @Override
+    public void serialize(Action action, ByteBuf outBuffer) {
+        // Serialize field type and save position
+        int startIndex = outBuffer.writerIndex();
+        outBuffer.writeShort(getType());
+        int lengthIndex = outBuffer.writerIndex();
+        outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH);
+
+        // Serialize match (using small workaround with serializeHeader method to serialize only match entries)
+        final SetField setField = SetFieldCase.class.cast(action).getSetField();
+        final HeaderSerializer<Match> serializer = registry
+                .getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Match.class));
+        serializer.serializeHeader(setField, outBuffer);
+
+        // Serialize padding based on match length
+        int paddingRemainder = (outBuffer.writerIndex() - startIndex) % EncodeConstants.PADDING;
+        if (paddingRemainder != 0) {
+            outBuffer.writeZero(EncodeConstants.PADDING - paddingRemainder);
+        }
+        outBuffer.setShort(lengthIndex, outBuffer.writerIndex() - startIndex);
+    }
+
+    @Override
+    protected int getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+    @Override
+    protected int getType() {
+        return ActionConstants.SET_FIELD_CODE;
+    }
+
+    @Override
+    public void injectSerializerRegistry(SerializerRegistry serializerRegistry) {
+        registry = serializerRegistry;
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetMplsTtlActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetMplsTtlActionSerializer.java
new file mode 100644 (file)
index 0000000..17769d2
--- /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.serialization.actions;
+
+import io.netty.buffer.ByteBuf;
+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 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlAction;
+
+public class SetMplsTtlActionSerializer extends AbstractActionSerializer {
+    @Override
+    public void serialize(Action action, ByteBuf outBuffer) {
+        super.serialize(action, outBuffer);
+        final SetMplsTtlAction setMplsTtlAction = SetMplsTtlActionCase.class.cast(action).getSetMplsTtlAction();
+        outBuffer.writeByte(setMplsTtlAction.getMplsTtl());
+        outBuffer.writeZero(ActionConstants.SET_MPLS_TTL_PADDING);
+    }
+
+    @Override
+    protected int getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+    @Override
+    protected int getType() {
+        return ActionConstants.SET_MPLS_TTL_CODE;
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwDstActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwDstActionSerializer.java
new file mode 100644 (file)
index 0000000..19e1af2
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * 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.serialization.actions;
+
+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 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.SetNwDstActionCase;
+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.action.types.rev131112.address.Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
+
+public class SetNwDstActionSerializer extends AbstractSetFieldActionSerializer {
+
+    @Override
+    protected SetFieldCase buildAction(Action input) {
+        final Address address = SetNwDstActionCase.class.cast(input).getSetNwDstAction().getAddress();
+        final SetFieldBuilder builder = new SetFieldBuilder();
+
+        if (Ipv4.class.isInstance(address)) {
+            builder.setLayer3Match(new Ipv4MatchBuilder()
+                    .setIpv4Destination(Ipv4.class.cast(address).getIpv4Address())
+                    .build());
+        } else if (Ipv6.class.isInstance(address)) {
+            builder.setLayer3Match(new Ipv6MatchBuilder()
+                    .setIpv6Destination(Ipv6.class.cast(address).getIpv6Address())
+                    .build());
+        }
+
+        return new SetFieldCaseBuilder().setSetField(builder.build()).build();
+    }
+
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwSrcActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwSrcActionSerializer.java
new file mode 100644 (file)
index 0000000..bafcf4d
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * 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.serialization.actions;
+
+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 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.SetNwSrcActionCase;
+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.action.types.rev131112.address.Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
+
+public class SetNwSrcActionSerializer extends AbstractSetFieldActionSerializer {
+
+    @Override
+    protected SetFieldCase buildAction(Action input) {
+        final Address address = SetNwSrcActionCase.class.cast(input).getSetNwSrcAction().getAddress();
+        final SetFieldBuilder builder = new SetFieldBuilder();
+
+        if (Ipv4.class.isInstance(address)) {
+            builder.setLayer3Match(new Ipv4MatchBuilder()
+                    .setIpv4Source(Ipv4.class.cast(address).getIpv4Address())
+                    .build());
+        } else if (Ipv6.class.isInstance(address)) {
+            builder.setLayer3Match(new Ipv6MatchBuilder()
+                    .setIpv6Source(Ipv6.class.cast(address).getIpv6Address())
+                    .build());
+        }
+
+        return new SetFieldCaseBuilder().setSetField(builder.build()).build();
+    }
+
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwTosActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwTosActionSerializer.java
new file mode 100644 (file)
index 0000000..edce954
--- /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.serialization.actions;
+
+import org.opendaylight.openflowplugin.openflow.md.util.ActionUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Dscp;
+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 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.SetNwTosActionCase;
+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.model.match.types.rev131026.match.IpMatchBuilder;
+
+public class SetNwTosActionSerializer extends AbstractSetFieldActionSerializer {
+
+    @Override
+    protected SetFieldCase buildAction(Action input) {
+        return new SetFieldCaseBuilder()
+                .setSetField(new SetFieldBuilder()
+                        .setIpMatch(new IpMatchBuilder()
+                                .setIpDscp(new Dscp(
+                                        ActionUtil.tosToDscp(SetNwTosActionCase.class.cast(input)
+                                                .getSetNwTosAction().getTos().shortValue())))
+                                .build())
+                        .build())
+                .build();
+    }
+
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwTtlActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwTtlActionSerializer.java
new file mode 100644 (file)
index 0000000..db93e8e
--- /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.serialization.actions;
+
+import io.netty.buffer.ByteBuf;
+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 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.ttl.action._case.SetNwTtlAction;
+
+public class SetNwTtlActionSerializer extends AbstractActionSerializer {
+    @Override
+    public void serialize(Action action, ByteBuf outBuffer) {
+        super.serialize(action, outBuffer);
+        final SetNwTtlAction setNwTtlAction = SetNwTtlActionCase.class.cast(action).getSetNwTtlAction();
+        outBuffer.writeByte(setNwTtlAction.getNwTtl());
+        outBuffer.writeZero(ActionConstants.SET_NW_TTL_PADDING);
+    }
+
+    @Override
+    protected int getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+    @Override
+    protected int getType() {
+        return ActionConstants.SET_NW_TTL_CODE;
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetQueueActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetQueueActionSerializer.java
new file mode 100644 (file)
index 0000000..4b0f668
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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.serialization.actions;
+
+import io.netty.buffer.ByteBuf;
+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 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueAction;
+
+public class SetQueueActionSerializer extends AbstractActionSerializer {
+    @Override
+    public void serialize(Action action, ByteBuf outBuffer) {
+        super.serialize(action, outBuffer);
+        final SetQueueAction setQueueAction = SetQueueActionCase.class.cast(action).getSetQueueAction();
+        outBuffer.writeByte(setQueueAction.getQueueId().intValue());
+    }
+
+    @Override
+    protected int getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+    @Override
+    protected int getType() {
+        return ActionConstants.SET_QUEUE_CODE;
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpDstActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpDstActionSerializer.java
new file mode 100644 (file)
index 0000000..31b828b
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * 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.serialization.actions;
+
+import java.util.Optional;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IPProtocols;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
+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 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.SetTpDstActionCase;
+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.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
+
+public class SetTpDstActionSerializer extends AbstractSetFieldActionSerializer {
+
+    @Override
+    protected SetFieldCase buildAction(Action input) {
+        final SetTpDstAction setTpDstAction = SetTpDstActionCase.class.cast(input).getSetTpDstAction();
+        final PortNumber port = setTpDstAction.getPort();
+        final SetFieldBuilder builder = new SetFieldBuilder();
+
+        Optional.ofNullable(IPProtocols.fromProtocolNum(setTpDstAction.getIpProtocol())).ifPresent(proto -> {
+            switch (proto) {
+                case ICMP: {
+                    builder.setIcmpv4Match(new Icmpv4MatchBuilder()
+                            .setIcmpv4Code((short) (0xFF & port.getValue()))
+                            .build());
+                    break;
+                }
+                case ICMPV6: {
+                    builder.setIcmpv6Match(new Icmpv6MatchBuilder()
+                            .setIcmpv6Code((short) (0xFF & port.getValue()))
+                            .build());
+                    break;
+                }
+                case TCP: {
+                    builder.setLayer4Match(new TcpMatchBuilder()
+                            .setTcpDestinationPort(port)
+                            .build());
+                    break;
+                }
+                case UDP: {
+                    builder.setLayer4Match(new UdpMatchBuilder()
+                            .setUdpDestinationPort(port)
+                            .build());
+                    break;
+                }
+            }
+        });
+
+        return new SetFieldCaseBuilder().setSetField(builder.build()).build();
+    }
+
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpSrcActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpSrcActionSerializer.java
new file mode 100644 (file)
index 0000000..b2cf4fa
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * 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.serialization.actions;
+
+import java.util.Optional;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IPProtocols;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
+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 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.SetTpSrcActionCase;
+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.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
+
+public class SetTpSrcActionSerializer extends AbstractSetFieldActionSerializer {
+
+    @Override
+    protected SetFieldCase buildAction(Action input) {
+        final SetTpSrcAction setTpSrcAction = SetTpSrcActionCase.class.cast(input).getSetTpSrcAction();
+        final PortNumber port = setTpSrcAction.getPort();
+        final SetFieldBuilder builder = new SetFieldBuilder();
+
+        Optional.ofNullable(IPProtocols.fromProtocolNum(setTpSrcAction.getIpProtocol())).ifPresent(proto -> {
+            switch (proto) {
+                case ICMP: {
+                    builder.setIcmpv4Match(new Icmpv4MatchBuilder()
+                            .setIcmpv4Type((short) (0xFF & port.getValue()))
+                            .build());
+                    break;
+                }
+                case ICMPV6: {
+                    builder.setIcmpv6Match(new Icmpv6MatchBuilder()
+                            .setIcmpv6Type((short) (0xFF & port.getValue()))
+                            .build());
+                    break;
+                }
+                case TCP: {
+                    builder.setLayer4Match(new TcpMatchBuilder()
+                            .setTcpSourcePort(port)
+                            .build());
+                    break;
+                }
+                case UDP: {
+                    builder.setLayer4Match(new UdpMatchBuilder()
+                            .setUdpSourcePort(port)
+                            .build());
+                    break;
+                }
+            }
+        });
+
+        return new SetFieldCaseBuilder().setSetField(builder.build()).build();
+    }
+
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetVlanIdActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetVlanIdActionSerializer.java
new file mode 100644 (file)
index 0000000..f6ffd75
--- /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.serialization.actions;
+
+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 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.SetVlanIdActionCase;
+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.model.match.types.rev131026.match.VlanMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
+
+public class SetVlanIdActionSerializer extends AbstractSetFieldActionSerializer {
+
+    @Override
+    protected SetFieldCase buildAction(Action input) {
+        return new SetFieldCaseBuilder()
+                .setSetField(new SetFieldBuilder()
+                        .setVlanMatch(new VlanMatchBuilder()
+                                .setVlanId(new VlanIdBuilder()
+                                        .setVlanIdPresent(true)
+                                        .setVlanId(SetVlanIdActionCase.class.cast(input).getSetVlanIdAction().getVlanId())
+                                        .build())
+                                .build())
+                        .build())
+                .build();
+    }
+
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetVlanPcpActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetVlanPcpActionSerializer.java
new file mode 100644 (file)
index 0000000..a99d7bb
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * 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.serialization.actions;
+
+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 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.SetVlanPcpActionCase;
+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.model.match.types.rev131026.match.VlanMatchBuilder;
+
+public class SetVlanPcpActionSerializer extends AbstractSetFieldActionSerializer {
+
+    @Override
+    protected SetFieldCase buildAction(Action input) {
+        return new SetFieldCaseBuilder()
+                .setSetField(new SetFieldBuilder()
+                        .setVlanMatch(new VlanMatchBuilder()
+                                .setVlanPcp((SetVlanPcpActionCase.class.cast(input).getSetVlanPcpAction().getVlanPcp()))
+                                .build())
+                        .build())
+                .build();
+    }
+
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/StripVlanActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/StripVlanActionSerializer.java
new file mode 100644 (file)
index 0000000..e1dc956
--- /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.serialization.actions;
+
+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 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.l2.types.rev130827.VlanId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
+
+public class StripVlanActionSerializer extends AbstractSetFieldActionSerializer {
+
+    @Override
+    protected SetFieldCase buildAction(Action input) {
+        return new SetFieldCaseBuilder()
+                .setSetField(new SetFieldBuilder()
+                        .setVlanMatch(new VlanMatchBuilder()
+                                .setVlanId(new VlanIdBuilder()
+                                        .setVlanIdPresent(true)
+                                        .setVlanId(new VlanId(0x0000))
+                                        .build())
+                                .build())
+                        .build())
+                .build();
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/CopyTtlInActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/CopyTtlInActionSerializerTest.java
new file mode 100644 (file)
index 0000000..667f387
--- /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.serialization.actions;
+
+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 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;
+
+public class CopyTtlInActionSerializerTest extends AbstractActionSerializerTest {
+
+    @Test
+    public void testSerialize() throws Exception {
+        final Action action = new CopyTtlInCaseBuilder()
+                .setCopyTtlIn(new CopyTtlInBuilder()
+                        .build())
+                .build();
+
+        assertAction(action, out -> out.skipBytes(ActionConstants.PADDING_IN_ACTION_HEADER));
+    }
+
+    @Override
+    protected Class<? extends Action> getClazz() {
+        return CopyTtlInCase.class;
+    }
+
+    @Override
+    protected int getType() {
+        return ActionConstants.COPY_TTL_IN_CODE;
+    }
+
+    @Override
+    protected int getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+}
\ No newline at end of file
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/CopyTtlOutActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/CopyTtlOutActionSerializerTest.java
new file mode 100644 (file)
index 0000000..14f90b2
--- /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.serialization.actions;
+
+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 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;
+
+public class CopyTtlOutActionSerializerTest extends AbstractActionSerializerTest {
+
+    @Test
+    public void testSerialize() throws Exception {
+        final Action action = new CopyTtlOutCaseBuilder()
+                .setCopyTtlOut(new CopyTtlOutBuilder()
+                        .build())
+                .build();
+
+        assertAction(action, out -> out.skipBytes(ActionConstants.PADDING_IN_ACTION_HEADER));
+    }
+
+    @Override
+    protected Class<? extends Action> getClazz() {
+        return CopyTtlOutCase.class;
+    }
+
+    @Override
+    protected int getType() {
+        return ActionConstants.COPY_TTL_OUT_CODE;
+    }
+
+    @Override
+    protected int getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/DecMplsTtlActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/DecMplsTtlActionSerializerTest.java
new file mode 100644 (file)
index 0000000..415c7e5
--- /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.serialization.actions;
+
+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 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;
+
+public class DecMplsTtlActionSerializerTest extends AbstractActionSerializerTest {
+
+    @Test
+    public void testSerialize() throws Exception {
+        final Action action = new DecMplsTtlCaseBuilder()
+                .setDecMplsTtl(new DecMplsTtlBuilder()
+                        .build())
+                .build();
+
+        assertAction(action, out -> out.skipBytes(ActionConstants.PADDING_IN_ACTION_HEADER));
+    }
+
+    @Override
+    protected Class<? extends Action> getClazz() {
+        return DecMplsTtlCase.class;
+    }
+
+    @Override
+    protected int getType() {
+        return ActionConstants.DEC_MPLS_TTL_CODE;
+    }
+
+    @Override
+    protected int getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/DecNwTtlActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/DecNwTtlActionSerializerTest.java
new file mode 100644 (file)
index 0000000..6d3fa18
--- /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.serialization.actions;
+
+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 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;
+
+public class DecNwTtlActionSerializerTest extends AbstractActionSerializerTest {
+
+    @Test
+    public void testSerialize() throws Exception {
+        final Action action = new DecNwTtlCaseBuilder()
+                .setDecNwTtl(new DecNwTtlBuilder()
+                        .build())
+                .build();
+
+        assertAction(action, out -> out.skipBytes(ActionConstants.PADDING_IN_ACTION_HEADER));
+    }
+
+    @Override
+    protected Class<? extends Action> getClazz() {
+        return DecNwTtlCase.class;
+    }
+
+    @Override
+    protected int getType() {
+        return ActionConstants.DEC_NW_TTL_CODE;
+    }
+
+    @Override
+    protected int getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/GroupActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/GroupActionSerializerTest.java
new file mode 100644 (file)
index 0000000..47fcf4b
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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.serialization.actions;
+
+import static org.junit.Assert.assertEquals;
+
+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 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;
+
+public class GroupActionSerializerTest extends AbstractActionSerializerTest {
+
+    @Test
+    public void testSerialize() throws Exception {
+        final long group = 10L;
+
+        final Action action = new GroupActionCaseBuilder()
+                .setGroupAction(new GroupActionBuilder()
+                        .setGroupId(group)
+                        .build())
+                .build();
+
+        assertAction(action, out -> assertEquals(out.readUnsignedInt(), group));
+    }
+
+    @Override
+    protected Class<? extends Action> getClazz() {
+        return GroupActionCase.class;
+    }
+
+    @Override
+    protected int getType() {
+        return ActionConstants.GROUP_CODE;
+    }
+
+    @Override
+    protected int getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/OutputActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/OutputActionSerializerTest.java
new file mode 100644 (file)
index 0000000..1e114c2
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * 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.serialization.actions;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.BinContent;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+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.OutputActionCase;
+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 org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumberValues;
+
+public class OutputActionSerializerTest extends AbstractActionSerializerTest {
+
+    @Test
+    public void testSerialize() throws Exception {
+        final int length = 10;
+        final String port = OutputPortValues.LOCAL.toString();
+
+        final Action action = new OutputActionCaseBuilder()
+                .setOutputAction(new OutputActionBuilder()
+                        .setOutputNodeConnector(new Uri("openflow:1:" + port))
+                        .setMaxLength(length)
+                        .build())
+                .build();
+
+        assertAction(action, out -> {
+            assertEquals(out.readUnsignedInt(), BinContent.intToUnsignedLong(PortNumberValues.LOCAL.getIntValue()));
+            assertEquals(out.readUnsignedShort(), length);
+            out.skipBytes(ActionConstants.OUTPUT_PADDING);
+        });
+    }
+
+    @Override
+    protected Class<? extends Action> getClazz() {
+        return OutputActionCase.class;
+    }
+
+    @Override
+    protected int getType() {
+        return ActionConstants.OUTPUT_CODE;
+    }
+
+    @Override
+    protected int getLength() {
+        return ActionConstants.LARGER_ACTION_LENGTH;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PopMplsActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PopMplsActionSerializerTest.java
new file mode 100644 (file)
index 0000000..253054d
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * 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.serialization.actions;
+
+import static org.junit.Assert.assertEquals;
+
+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.PopMplsActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder;
+
+public class PopMplsActionSerializerTest extends AbstractActionSerializerTest {
+
+    @Test
+    public void testSerialize() throws Exception {
+        final int ethType = 10;
+
+        final Action action = new PopMplsActionCaseBuilder()
+                .setPopMplsAction(new PopMplsActionBuilder()
+                        .setEthernetType(ethType)
+                        .build())
+                .build();
+
+        assertAction(action, out -> {
+            assertEquals(out.readUnsignedShort(), ethType);
+            out.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING);
+        });
+    }
+
+    @Override
+    protected Class<? extends Action> getClazz() {
+        return PopMplsActionCase.class;
+    }
+
+    @Override
+    protected int getType() {
+        return ActionConstants.POP_MPLS_CODE;
+    }
+
+    @Override
+    protected int getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PopPbbActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PopPbbActionSerializerTest.java
new file mode 100644 (file)
index 0000000..4461580
--- /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.serialization.actions;
+
+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 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;
+
+public class PopPbbActionSerializerTest extends AbstractActionSerializerTest {
+
+    @Test
+    public void testSerialize() throws Exception {
+        final Action action = new PopPbbActionCaseBuilder()
+                .setPopPbbAction(new PopPbbActionBuilder()
+                        .build())
+                .build();
+
+        assertAction(action, out -> out.skipBytes(ActionConstants.PADDING_IN_ACTION_HEADER));
+    }
+
+    @Override
+    protected Class<? extends Action> getClazz() {
+        return PopPbbActionCase.class;
+    }
+
+    @Override
+    protected int getType() {
+        return ActionConstants.POP_PBB_CODE;
+    }
+
+    @Override
+    protected int getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PopVlanActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PopVlanActionSerializerTest.java
new file mode 100644 (file)
index 0000000..302e1ba
--- /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.serialization.actions;
+
+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 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;
+
+public class PopVlanActionSerializerTest extends AbstractActionSerializerTest {
+
+    @Test
+    public void testSerialize() throws Exception {
+        final Action action = new PopVlanActionCaseBuilder()
+                .setPopVlanAction(new PopVlanActionBuilder()
+                        .build())
+                .build();
+
+        assertAction(action, out -> out.skipBytes(ActionConstants.PADDING_IN_ACTION_HEADER));
+    }
+
+    @Override
+    protected Class<? extends Action> getClazz() {
+        return PopVlanActionCase.class;
+    }
+
+    @Override
+    protected int getType() {
+        return ActionConstants.POP_VLAN_CODE;
+    }
+
+    @Override
+    protected int getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushMplsActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushMplsActionSerializerTest.java
new file mode 100644 (file)
index 0000000..24dfa5f
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * 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.serialization.actions;
+
+import static org.junit.Assert.assertEquals;
+
+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 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;
+
+public class PushMplsActionSerializerTest extends AbstractActionSerializerTest {
+
+    @Test
+    public void testSerialize() throws Exception {
+        final int ethType = 10;
+
+        final Action action = new PushMplsActionCaseBuilder()
+                .setPushMplsAction(new PushMplsActionBuilder()
+                        .setEthernetType(ethType)
+                        .build())
+                .build();
+
+        assertAction(action, out -> {
+            assertEquals(out.readUnsignedShort(), ethType);
+            out.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING);
+        });
+    }
+
+    @Override
+    protected Class<? extends Action> getClazz() {
+        return PushMplsActionCase.class;
+    }
+
+    @Override
+    protected int getType() {
+        return ActionConstants.PUSH_MPLS_CODE;
+    }
+
+    @Override
+    protected int getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushPbbActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushPbbActionSerializerTest.java
new file mode 100644 (file)
index 0000000..9ac7fa8
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * 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.serialization.actions;
+
+import static org.junit.Assert.assertEquals;
+
+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 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;
+
+public class PushPbbActionSerializerTest extends AbstractActionSerializerTest {
+
+    @Test
+    public void testSerialize() throws Exception {
+        final int ethType = 10;
+
+        final Action action = new PushPbbActionCaseBuilder()
+                .setPushPbbAction(new PushPbbActionBuilder()
+                        .setEthernetType(ethType)
+                        .build())
+                .build();
+
+        assertAction(action, out -> {
+            assertEquals(out.readUnsignedShort(), ethType);
+            out.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING);
+        });
+    }
+
+    @Override
+    protected Class<? extends Action> getClazz() {
+        return PushPbbActionCase.class;
+    }
+
+    @Override
+    protected int getType() {
+        return ActionConstants.PUSH_PBB_CODE;
+    }
+
+    @Override
+    protected int getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushVlanActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushVlanActionSerializerTest.java
new file mode 100644 (file)
index 0000000..731ce1d
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * 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.serialization.actions;
+
+import static org.junit.Assert.assertEquals;
+
+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 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;
+
+public class PushVlanActionSerializerTest extends AbstractActionSerializerTest {
+
+    @Test
+    public void testSerialize() throws Exception {
+        final int ethType = 10;
+
+        final Action action = new PushVlanActionCaseBuilder()
+                .setPushVlanAction(new PushVlanActionBuilder()
+                        .setEthernetType(ethType)
+                        .build())
+                .build();
+
+        assertAction(action, out -> {
+            assertEquals(out.readUnsignedShort(), ethType);
+            out.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING);
+        });
+    }
+
+    @Override
+    protected Class<? extends Action> getClazz() {
+        return PushVlanActionCase.class;
+    }
+
+    @Override
+    protected int getType() {
+        return ActionConstants.PUSH_VLAN_CODE;
+    }
+
+    @Override
+    protected int getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetDlDstActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetDlDstActionSerializerTest.java
new file mode 100644 (file)
index 0000000..7f09a69
--- /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.serialization.actions;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+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.SetDlDstActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstActionBuilder;
+
+public class SetDlDstActionSerializerTest extends AbstractSetFieldActionSerializerTest {
+
+    @Test
+    public void testSerialize() throws Exception {
+        final MacAddress address = new MacAddress("00:01:02:03:04:05");
+
+        final Action action = new SetDlDstActionCaseBuilder()
+                .setSetDlDstAction(new SetDlDstActionBuilder()
+                        .setAddress(address)
+                        .build())
+                .build();
+
+        assertAction(action, out -> {
+            byte[] addressBytes = new byte[6];
+            out.readBytes(addressBytes);
+            assertEquals(new MacAddress(ByteBufUtils.macAddressToString(addressBytes)).getValue(), address.getValue());
+        });
+    }
+
+    @Override
+    protected Class<? extends Action> getClazz() {
+        return SetDlDstActionCase.class;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetDlSrcActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetDlSrcActionSerializerTest.java
new file mode 100644 (file)
index 0000000..03249df
--- /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.serialization.actions;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+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.SetDlSrcActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcActionBuilder;
+
+public class SetDlSrcActionSerializerTest extends AbstractSetFieldActionSerializerTest {
+
+    @Test
+    public void testSerialize() throws Exception {
+        final MacAddress address = new MacAddress("00:01:02:03:04:05");
+
+        final Action action = new SetDlSrcActionCaseBuilder()
+                .setSetDlSrcAction(new SetDlSrcActionBuilder()
+                        .setAddress(address)
+                        .build())
+                .build();
+
+        assertAction(action, out -> {
+            byte[] addressBytes = new byte[6];
+            out.readBytes(addressBytes);
+            assertEquals(new MacAddress(ByteBufUtils.macAddressToString(addressBytes)).getValue(), address.getValue());
+        });
+    }
+
+    @Override
+    protected Class<? extends Action> getClazz() {
+        return SetDlSrcActionCase.class;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetMplsTtlActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetMplsTtlActionSerializerTest.java
new file mode 100644 (file)
index 0000000..36bec2f
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * 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.serialization.actions;
+
+import static org.junit.Assert.assertEquals;
+
+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 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;
+
+public class SetMplsTtlActionSerializerTest extends AbstractActionSerializerTest {
+
+    @Test
+    public void testSerialize() throws Exception {
+        final short mpls = (short) 10;
+
+        final Action action = new SetMplsTtlActionCaseBuilder()
+                .setSetMplsTtlAction(new SetMplsTtlActionBuilder()
+                        .setMplsTtl(mpls)
+                        .build())
+                .build();
+
+        assertAction(action, out -> {
+            assertEquals(out.readUnsignedByte(), mpls);
+            out.skipBytes(ActionConstants.SET_MPLS_TTL_PADDING);
+        });
+    }
+
+    @Override
+    protected Class<? extends Action> getClazz() {
+        return SetMplsTtlActionCase.class;
+    }
+
+    @Override
+    protected int getType() {
+        return ActionConstants.SET_MPLS_TTL_CODE;
+    }
+
+    @Override
+    protected int getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwDstActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwDstActionSerializerTest.java
new file mode 100644 (file)
index 0000000..25b25dc
--- /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.serialization.actions;
+
+import static org.junit.Assert.assertArrayEquals;
+
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
+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.SetNwDstActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
+
+public class SetNwDstActionSerializerTest extends AbstractSetFieldActionSerializerTest {
+
+    @Test
+    public void testSerialize() throws Exception {
+        final Ipv4 address = new Ipv4Builder()
+                .setIpv4Address(new Ipv4Prefix("192.168.76.2/32"))
+                .build();
+
+        final Action action = new SetNwDstActionCaseBuilder()
+                .setSetNwDstAction(new SetNwDstActionBuilder()
+                        .setAddress(address)
+                        .build())
+                .build();
+
+        assertAction(action, out -> {
+            byte[] addressBytes = new byte[4];
+            out.readBytes(addressBytes);
+            assertArrayEquals(addressBytes, new byte[] { (byte) 192, (byte) 168, 76, 2 });
+        });
+    }
+
+    @Override
+    protected Class<? extends Action> getClazz() {
+        return SetNwDstActionCase.class;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwSrcActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwSrcActionSerializerTest.java
new file mode 100644 (file)
index 0000000..974d831
--- /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.serialization.actions;
+
+import static org.junit.Assert.assertArrayEquals;
+
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
+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.SetNwSrcActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
+
+public class SetNwSrcActionSerializerTest extends AbstractSetFieldActionSerializerTest {
+
+    @Test
+    public void testSerialize() throws Exception {
+        final Ipv4 address = new Ipv4Builder()
+                .setIpv4Address(new Ipv4Prefix("192.168.76.2/32"))
+                .build();
+
+        final Action action = new SetNwSrcActionCaseBuilder()
+                .setSetNwSrcAction(new SetNwSrcActionBuilder()
+                        .setAddress(address)
+                        .build())
+                .build();
+
+        assertAction(action, out -> {
+            byte[] addressBytes = new byte[4];
+            out.readBytes(addressBytes);
+            assertArrayEquals(addressBytes, new byte[] { (byte) 192, (byte) 168, 76, 2 });
+        });
+    }
+
+    @Override
+    protected Class<? extends Action> getClazz() {
+        return SetNwSrcActionCase.class;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwTosActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwTosActionSerializerTest.java
new file mode 100644 (file)
index 0000000..6953018
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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.serialization.actions;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.opendaylight.openflowplugin.openflow.md.util.ActionUtil;
+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.SetNwTosActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosActionBuilder;
+
+public class SetNwTosActionSerializerTest extends AbstractSetFieldActionSerializerTest {
+
+    @Test
+    public void testSerialize() throws Exception {
+        final int tos = 10;
+
+        final Action action = new SetNwTosActionCaseBuilder()
+                .setSetNwTosAction(new SetNwTosActionBuilder()
+                        .setTos(10)
+                        .build())
+                .build();
+
+        assertAction(action, out -> assertEquals(out.readUnsignedByte(), (short) ActionUtil.tosToDscp((short) tos)));
+    }
+
+    @Override
+    protected Class<? extends Action> getClazz() {
+        return SetNwTosActionCase.class;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwTtlActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwTtlActionSerializerTest.java
new file mode 100644 (file)
index 0000000..7eadf5c
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * 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.serialization.actions;
+
+import static org.junit.Assert.assertEquals;
+
+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 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;
+
+public class SetNwTtlActionSerializerTest extends AbstractActionSerializerTest {
+
+    @Test
+    public void testSerialize() throws Exception {
+        final short ttl = 10;
+
+        final Action action = new SetNwTtlActionCaseBuilder()
+                .setSetNwTtlAction(new SetNwTtlActionBuilder()
+                        .setNwTtl(ttl)
+                        .build())
+                .build();
+
+        assertAction(action, out -> {
+            assertEquals(out.readUnsignedByte(), ttl);
+            out.skipBytes(ActionConstants.SET_NW_TTL_PADDING);
+        });
+    }
+
+    @Override
+    protected Class<? extends Action> getClazz() {
+        return SetNwTtlActionCase.class;
+    }
+
+    @Override
+    protected int getType() {
+        return ActionConstants.SET_NW_TTL_CODE;
+    }
+
+    @Override
+    protected int getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetQueueActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetQueueActionSerializerTest.java
new file mode 100644 (file)
index 0000000..6e8c9f4
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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.serialization.actions;
+
+import static org.junit.Assert.assertEquals;
+
+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 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;
+
+public class SetQueueActionSerializerTest extends AbstractActionSerializerTest {
+
+    @Test
+    public void testSerialize() throws Exception {
+        final long queue = 10;
+
+        final Action action = new SetQueueActionCaseBuilder()
+                .setSetQueueAction(new SetQueueActionBuilder()
+                        .setQueueId(queue)
+                        .build())
+                .build();
+
+        assertAction(action, out -> assertEquals(out.readUnsignedByte(), queue));
+    }
+
+    @Override
+    protected Class<? extends Action> getClazz() {
+        return SetQueueActionCase.class;
+    }
+
+    @Override
+    protected int getType() {
+        return ActionConstants.SET_QUEUE_CODE;
+    }
+
+    @Override
+    protected int getLength() {
+        return ActionConstants.GENERAL_ACTION_LENGTH;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpDstActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpDstActionSerializerTest.java
new file mode 100644 (file)
index 0000000..65e1a84
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * 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.serialization.actions;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
+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.SetTpDstActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstActionBuilder;
+
+public class SetTpDstActionSerializerTest extends AbstractSetFieldActionSerializerTest {
+
+    @Test
+    public void testSerialize() throws Exception {
+        final PortNumber port = new PortNumber(20);
+        final short protocol = 6; // TCP
+
+        final Action action = new SetTpDstActionCaseBuilder()
+                .setSetTpDstAction(new SetTpDstActionBuilder()
+                        .setPort(port)
+                        .setIpProtocol(protocol)
+                        .build())
+                .build();
+
+        assertAction(action, out -> assertEquals(Integer.valueOf(out.readUnsignedShort()), port.getValue()));
+    }
+
+    @Override
+    protected Class<? extends Action> getClazz() {
+        return SetTpDstActionCase.class;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpSrcActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpSrcActionSerializerTest.java
new file mode 100644 (file)
index 0000000..95e2827
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * 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.serialization.actions;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
+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.SetTpSrcActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcActionBuilder;
+
+public class SetTpSrcActionSerializerTest extends AbstractSetFieldActionSerializerTest {
+
+    @Test
+    public void testSerialize() throws Exception {
+        final PortNumber port = new PortNumber(20);
+        final short protocol = 6; // TCP
+
+        final Action action = new SetTpSrcActionCaseBuilder()
+                .setSetTpSrcAction(new SetTpSrcActionBuilder()
+                        .setPort(port)
+                        .setIpProtocol(protocol)
+                        .build())
+                .build();
+
+        assertAction(action, out -> assertEquals(Integer.valueOf(out.readUnsignedShort()), port.getValue()));
+    }
+
+    @Override
+    protected Class<? extends Action> getClazz() {
+        return SetTpSrcActionCase.class;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetVlanIdActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetVlanIdActionSerializerTest.java
new file mode 100644 (file)
index 0000000..cf8fab3
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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.serialization.actions;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+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.SetVlanIdActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
+
+public class SetVlanIdActionSerializerTest extends AbstractSetFieldActionSerializerTest {
+
+    @Test
+    public void testSerialize() throws Exception {
+        final int vlan = 1;
+
+        final Action action = new SetVlanIdActionCaseBuilder()
+                .setSetVlanIdAction(new SetVlanIdActionBuilder()
+                        .setVlanId(new VlanId(vlan))
+                        .build())
+                .build();
+
+        assertAction(action, out -> assertEquals(out.readShort(), vlan | (1 << 12)));
+    }
+
+    @Override
+    protected Class<? extends Action> getClazz() {
+        return SetVlanIdActionCase.class;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetVlanPcpActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetVlanPcpActionSerializerTest.java
new file mode 100644 (file)
index 0000000..c03de2b
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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.serialization.actions;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+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.SetVlanPcpActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp;
+
+public class SetVlanPcpActionSerializerTest extends AbstractSetFieldActionSerializerTest {
+
+    @Test
+    public void testSerialize() throws Exception {
+        final short vlan = 1;
+
+        final Action action = new SetVlanPcpActionCaseBuilder()
+                .setSetVlanPcpAction(new SetVlanPcpActionBuilder()
+                        .setVlanPcp(new VlanPcp(vlan))
+                        .build())
+                .build();
+
+        assertAction(action, out -> assertEquals(out.readUnsignedByte(), vlan));
+    }
+
+    @Override
+    protected Class<? extends Action> getClazz() {
+        return SetVlanPcpActionCase.class;
+    }
+
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/StripVlanActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/StripVlanActionSerializerTest.java
new file mode 100644 (file)
index 0000000..14b8e04
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * 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.serialization.actions;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+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.StripVlanActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.StripVlanActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.strip.vlan.action._case.StripVlanActionBuilder;
+
+public class StripVlanActionSerializerTest extends AbstractSetFieldActionSerializerTest {
+
+    @Test
+    public void testSerialize() throws Exception {
+        final Action action = new StripVlanActionCaseBuilder()
+                .setStripVlanAction(new StripVlanActionBuilder()
+                        .build())
+                .build();
+
+        assertAction(action, out -> {
+            assertEquals(out.readUnsignedShort(), (1 << 12));
+            byte[] mask = new byte[2];
+            out.readBytes(mask);
+            assertArrayEquals(mask, new byte[] { 16, 0 });
+        });
+    }
+
+    @Override
+    protected Class<? extends Action> getClazz() {
+        return StripVlanActionCase.class;
+    }
+
+}