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
// 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());
}
/**
new MessageTypeKey<>(version, type),
serializer);
}
-}
\ No newline at end of file
+}
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 {
@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);
}
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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();
+ }
+
+}
--- /dev/null
+/*
+ * 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();
+ }
+
+}
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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();
+ }
+
+}
--- /dev/null
+/*
+ * 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();
+ }
+
+}
--- /dev/null
+/*
+ * 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();
+ }
+
+}
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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();
+ }
+
+}
--- /dev/null
+/*
+ * 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();
+ }
+
+}
--- /dev/null
+/*
+ * 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();
+ }
+
+}
--- /dev/null
+/*
+ * 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();
+ }
+
+}
--- /dev/null
+/*
+ * 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();
+ }
+
+}
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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;
+ }
+
+}
--- /dev/null
+/*
+ * 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;
+ }
+
+}
--- /dev/null
+/*
+ * 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;
+ }
+
+}
--- /dev/null
+/*
+ * 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;
+ }
+
+}
--- /dev/null
+/*
+ * 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;
+ }
+
+}
--- /dev/null
+/*
+ * 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;
+ }
+
+}
--- /dev/null
+/*
+ * 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;
+ }
+
+}
--- /dev/null
+/*
+ * 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;
+ }
+
+}
--- /dev/null
+/*
+ * 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;
+ }
+
+}
--- /dev/null
+/*
+ * 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;
+ }
+
+}
--- /dev/null
+/*
+ * 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;
+ }
+
+}
--- /dev/null
+/*
+ * 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;
+ }
+
+}
--- /dev/null
+/*
+ * 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;
+ }
+
+}
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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;
+ }
+
+}
--- /dev/null
+/*
+ * 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;
+ }
+
+}
--- /dev/null
+/*
+ * 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;
+ }
+
+}
--- /dev/null
+/*
+ * 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;
+ }
+
+}
--- /dev/null
+/*
+ * 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;
+ }
+
+}
--- /dev/null
+/*
+ * 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;
+ }
+
+}
--- /dev/null
+/*
+ * 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;
+ }
+
+}
--- /dev/null
+/*
+ * 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;
+ }
+
+}
--- /dev/null
+/*
+ * 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;
+ }
+
+}
--- /dev/null
+/*
+ * 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;
+ }
+
+}