Inject action deserializers into DeserializerRegistry.
These deserializers will deserialize these actions:
- CopyTtlIn
- CopyTtlOut
- DecMplsTtl
- DecNwTtl
- Group
- Output
- PopMpls
- PopPbb
- PopVlan
- PushMpls
- PushPbb
- PushVlan
- SetField
- SetMplsTtl
- SetNwTtl
- SetQueue
See also: bug 7140
Change-Id: I0f36092ca99de0ca51719c3c2099ebe1d904a72f
Signed-off-by: Tomas Slusny <tomas.slusny@pantheon.tech>
import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerExtensionProvider;
import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
import org.opendaylight.openflowplugin.api.openflow.protocol.deserialization.MessageCodeExperimenterKey;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.action.CopyTtlInActionDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.action.CopyTtlOutActionDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.action.DecMplsTtlActionDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.action.DecNwTtlActionDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.action.GroupActionDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.action.OutputActionDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.action.PopMplsActionDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.action.PopPbbActionDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.action.PopVlanActionDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.action.PushMplsActionDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.action.PushPbbActionDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.action.PushVlanActionDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.action.SetFieldActionDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.action.SetMplsTtlActionDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.action.SetNwTtlActionDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.action.SetQueueActionDeserializer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
import com.google.common.annotations.VisibleForTesting;
// Inject new message deserializers here using injector created by createInjector method
final Function<Byte, Consumer<OFDeserializer<Action>>> injector =
createInjector(provider, EncodeConstants.OF13_VERSION_ID);
+
+ injector.apply(ActionConstants.COPY_TTL_IN_CODE).accept(new CopyTtlInActionDeserializer());
+ injector.apply(ActionConstants.COPY_TTL_OUT_CODE).accept(new CopyTtlOutActionDeserializer());
+ injector.apply(ActionConstants.OUTPUT_CODE).accept(new OutputActionDeserializer());
+ injector.apply(ActionConstants.DEC_MPLS_TTL_CODE).accept(new DecMplsTtlActionDeserializer());
+ injector.apply(ActionConstants.DEC_NW_TTL_CODE).accept(new DecNwTtlActionDeserializer());
+ injector.apply(ActionConstants.GROUP_CODE).accept(new GroupActionDeserializer());
+ injector.apply(ActionConstants.POP_MPLS_CODE).accept(new PopMplsActionDeserializer());
+ injector.apply(ActionConstants.POP_PBB_CODE).accept(new PopPbbActionDeserializer());
+ injector.apply(ActionConstants.POP_VLAN_CODE).accept(new PopVlanActionDeserializer());
+ injector.apply(ActionConstants.PUSH_MPLS_CODE).accept(new PushMplsActionDeserializer());
+ injector.apply(ActionConstants.PUSH_PBB_CODE).accept(new PushPbbActionDeserializer());
+ injector.apply(ActionConstants.PUSH_VLAN_CODE).accept(new PushVlanActionDeserializer());
+ injector.apply(ActionConstants.SET_MPLS_TTL_CODE).accept(new SetMplsTtlActionDeserializer());
+ injector.apply(ActionConstants.SET_NW_TTL_CODE).accept(new SetNwTtlActionDeserializer());
+ injector.apply(ActionConstants.SET_QUEUE_CODE).accept(new SetQueueActionDeserializer());
+ injector.apply((byte) ActionConstants.SET_FIELD_CODE).accept(new SetFieldActionDeserializer());
}
/**
--- /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.deserialization.action;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.in._case.CopyTtlInBuilder;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+
+import io.netty.buffer.ByteBuf;
+
+public class CopyTtlInActionDeserializer extends AbstractActionDeserializer {
+
+ @Override
+ public Action deserialize(ByteBuf message) {
+ processHeader(message);
+ message.skipBytes(ActionConstants.PADDING_IN_ACTION_HEADER);
+
+ return new CopyTtlInCaseBuilder()
+ .setCopyTtlIn(new CopyTtlInBuilder().build())
+ .build();
+ }
+
+ @Override
+ public Action deserializeHeader(ByteBuf message) {
+ processHeader(message);
+ return new CopyTtlInCaseBuilder().build();
+ }
+
+}
--- /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.deserialization.action;
+
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.out._case.CopyTtlOutBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+
+import io.netty.buffer.ByteBuf;
+
+public class CopyTtlOutActionDeserializer extends AbstractActionDeserializer {
+
+ @Override
+ public Action deserialize(ByteBuf message) {
+ processHeader(message);
+ message.skipBytes(ActionConstants.PADDING_IN_ACTION_HEADER);
+
+ return new CopyTtlOutCaseBuilder()
+ .setCopyTtlOut(new CopyTtlOutBuilder().build())
+ .build();
+ }
+
+
+ @Override
+ public Action deserializeHeader(ByteBuf message) {
+ processHeader(message);
+ return new CopyTtlOutCaseBuilder().build();
+ }
+
+}
--- /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.deserialization.action;
+
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.mpls.ttl._case.DecMplsTtlBuilder;
+
+import io.netty.buffer.ByteBuf;
+
+public class DecMplsTtlActionDeserializer extends AbstractActionDeserializer {
+
+ @Override
+ public Action deserialize(ByteBuf message) {
+ processHeader(message);
+ message.skipBytes(ActionConstants.PADDING_IN_ACTION_HEADER);
+
+ return new DecMplsTtlCaseBuilder()
+ .setDecMplsTtl(new DecMplsTtlBuilder().build())
+ .build();
+ }
+
+ @Override
+ public Action deserializeHeader(ByteBuf message) {
+ processHeader(message);
+ return new DecMplsTtlCaseBuilder().build();
+ }
+
+}
--- /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.deserialization.action;
+
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
+
+import io.netty.buffer.ByteBuf;
+
+public class DecNwTtlActionDeserializer extends AbstractActionDeserializer {
+
+ @Override
+ public Action deserialize(ByteBuf message) {
+ processHeader(message);
+ message.skipBytes(ActionConstants.PADDING_IN_ACTION_HEADER);
+
+ return new DecNwTtlCaseBuilder()
+ .setDecNwTtl(new DecNwTtlBuilder().build())
+ .build();
+ }
+
+ @Override
+ public Action deserializeHeader(ByteBuf message) {
+ processHeader(message);
+ return new DecNwTtlCaseBuilder().build();
+ }
+
+}
--- /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.deserialization.action;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder;
+
+import io.netty.buffer.ByteBuf;
+
+public class GroupActionDeserializer extends AbstractActionDeserializer {
+
+ @Override
+ public Action deserialize(ByteBuf message) {
+ processHeader(message);
+
+ return new GroupActionCaseBuilder()
+ .setGroupAction(new GroupActionBuilder()
+ .setGroupId(message.readUnsignedInt())
+ .build())
+ .build();
+ }
+
+ @Override
+ public Action deserializeHeader(ByteBuf message) {
+ processHeader(message);
+ return new GroupActionCaseBuilder().build();
+ }
+
+}
--- /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.deserialization.action;
+
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
+
+import io.netty.buffer.ByteBuf;
+
+public class OutputActionDeserializer extends AbstractActionDeserializer {
+
+ @Override
+ public Action deserialize(ByteBuf message) {
+ processHeader(message);
+
+ final String portNumberAsString = OpenflowPortsUtil
+ .portNumberToString(OpenflowPortsUtil
+ .getProtocolAgnosticPort(OpenflowVersion.OF13, message.readUnsignedInt()));
+
+ final int maxLength = message.readUnsignedShort();
+ message.skipBytes(ActionConstants.OUTPUT_PADDING);
+
+ return new OutputActionCaseBuilder()
+ .setOutputAction(new OutputActionBuilder()
+ .setOutputNodeConnector(new Uri(portNumberAsString))
+ .setMaxLength(maxLength)
+ .build())
+ .build();
+ }
+
+ @Override
+ public Action deserializeHeader(ByteBuf message) {
+ processHeader(message);
+ return new OutputActionCaseBuilder().build();
+ }
+
+}
--- /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.deserialization.action;
+
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder;
+
+import io.netty.buffer.ByteBuf;
+
+public class PopMplsActionDeserializer extends AbstractActionDeserializer {
+
+ @Override
+ public Action deserialize(ByteBuf message) {
+ processHeader(message);
+
+ final int ethType = message.readUnsignedShort();
+ message.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING);
+
+ return new PopMplsActionCaseBuilder()
+ .setPopMplsAction(new PopMplsActionBuilder()
+ .setEthernetType(ethType)
+ .build())
+ .build();
+ }
+
+ @Override
+ public Action deserializeHeader(ByteBuf message) {
+ processHeader(message);
+ return new PopMplsActionCaseBuilder().build();
+ }
+
+}
--- /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.deserialization.action;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.pbb.action._case.PopPbbActionBuilder;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+
+import io.netty.buffer.ByteBuf;
+
+public class PopPbbActionDeserializer extends AbstractActionDeserializer {
+
+ @Override
+ public Action deserialize(ByteBuf message) {
+ processHeader(message);
+ message.skipBytes(ActionConstants.PADDING_IN_ACTION_HEADER);
+
+ return new PopPbbActionCaseBuilder()
+ .setPopPbbAction(new PopPbbActionBuilder().build())
+ .build();
+ }
+
+ @Override
+ public Action deserializeHeader(ByteBuf message) {
+ processHeader(message);
+ return new PopPbbActionCaseBuilder().build();
+ }
+
+}
--- /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.deserialization.action;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+
+import io.netty.buffer.ByteBuf;
+
+public class PopVlanActionDeserializer extends AbstractActionDeserializer {
+
+ @Override
+ public Action deserialize(ByteBuf message) {
+ processHeader(message);
+ message.skipBytes(ActionConstants.PADDING_IN_ACTION_HEADER);
+
+ return new PopVlanActionCaseBuilder()
+ .setPopVlanAction(new PopVlanActionBuilder().build())
+ .build();
+ }
+
+ @Override
+ public Action deserializeHeader(ByteBuf message) {
+ processHeader(message);
+ return new PopVlanActionCaseBuilder().build();
+ }
+
+}
--- /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.deserialization.action;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+
+import io.netty.buffer.ByteBuf;
+
+public class PushMplsActionDeserializer extends AbstractActionDeserializer {
+
+ @Override
+ public Action deserialize(ByteBuf message) {
+ processHeader(message);
+ final int ethType = message.readUnsignedShort();
+ message.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING);
+
+ return new PushMplsActionCaseBuilder()
+ .setPushMplsAction(new PushMplsActionBuilder()
+ .setEthernetType(ethType)
+ .build())
+ .build();
+ }
+
+ @Override
+ public Action deserializeHeader(ByteBuf message) {
+ processHeader(message);
+ return new PushMplsActionCaseBuilder().build();
+ }
+
+}
--- /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.deserialization.action;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+
+import io.netty.buffer.ByteBuf;
+
+public class PushPbbActionDeserializer extends AbstractActionDeserializer {
+
+ @Override
+ public Action deserialize(ByteBuf message) {
+ processHeader(message);
+ final int ethType = message.readUnsignedShort();
+ message.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING);
+
+ return new PushPbbActionCaseBuilder()
+ .setPushPbbAction(new PushPbbActionBuilder()
+ .setEthernetType(ethType)
+ .build())
+ .build();
+ }
+
+ @Override
+ public Action deserializeHeader(ByteBuf message) {
+ processHeader(message);
+ return new PushPbbActionCaseBuilder().build();
+ }
+
+}
--- /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.deserialization.action;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+
+import io.netty.buffer.ByteBuf;
+
+public class PushVlanActionDeserializer extends AbstractActionDeserializer {
+
+ @Override
+ public Action deserialize(ByteBuf message) {
+ processHeader(message);
+ final int ethType = message.readUnsignedShort();
+ message.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING);
+
+ return new PushVlanActionCaseBuilder()
+ .setPushVlanAction(new PushVlanActionBuilder()
+ .setEthernetType(ethType)
+ .build())
+ .build();
+ }
+
+ @Override
+ public Action deserializeHeader(ByteBuf message) {
+ processHeader(message);
+ return new PushVlanActionCaseBuilder().build();
+ }
+
+}
--- /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.deserialization.action;
+
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowplugin.api.openflow.protocol.deserialization.MatchEntryDeserializer;
+import org.opendaylight.openflowplugin.extension.api.path.MatchPath;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.key.MessageCodeMatchKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
+
+import io.netty.buffer.ByteBuf;
+
+public class SetFieldActionDeserializer extends AbstractActionDeserializer
+ implements DeserializerRegistryInjector {
+
+ private static final MessageCodeKey MATCH_KEY = new MessageCodeMatchKey(
+ EncodeConstants.OF13_VERSION_ID,
+ EncodeConstants.EMPTY_LENGTH,
+ Match.class,
+ MatchPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_MATCH);
+
+ private DeserializerRegistry registry;
+
+ @Override
+ public Action deserialize(ByteBuf message) {
+ final MatchEntryDeserializer deserializer = registry.getDeserializer(MATCH_KEY);
+ final MatchBuilder builder = new MatchBuilder();
+
+ final int startIndex = message.readerIndex();
+ processHeader(message);
+ deserializer.deserializeEntry(message, builder);
+
+ int paddingRemainder = (message.readerIndex() - startIndex) % EncodeConstants.PADDING;
+ if (paddingRemainder != 0) {
+ message.skipBytes(EncodeConstants.PADDING - paddingRemainder);
+ }
+
+ return new SetFieldCaseBuilder()
+ .setSetField(new SetFieldBuilder(builder.build()).build())
+ .build();
+ }
+
+ @Override
+ public Action deserializeHeader(ByteBuf message) {
+ processHeader(message);
+ return new SetFieldCaseBuilder().build();
+ }
+
+ @Override
+ public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) {
+ registry = deserializerRegistry;
+ }
+
+}
--- /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.deserialization.action;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlActionBuilder;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+
+import io.netty.buffer.ByteBuf;
+
+public class SetMplsTtlActionDeserializer extends AbstractActionDeserializer {
+
+ @Override
+ public Action deserialize(ByteBuf message) {
+ processHeader(message);
+ final short mplsTtl = message.readUnsignedByte();
+ message.skipBytes(ActionConstants.SET_MPLS_TTL_PADDING);
+
+ return new SetMplsTtlActionCaseBuilder()
+ .setSetMplsTtlAction(new SetMplsTtlActionBuilder()
+ .setMplsTtl(mplsTtl)
+ .build())
+ .build();
+ }
+
+ @Override
+ public Action deserializeHeader(ByteBuf message) {
+ processHeader(message);
+ return new SetMplsTtlActionCaseBuilder().build();
+ }
+
+}
--- /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.deserialization.action;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.ttl.action._case.SetNwTtlActionBuilder;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+
+import io.netty.buffer.ByteBuf;
+
+public class SetNwTtlActionDeserializer extends AbstractActionDeserializer {
+
+ @Override
+ public Action deserialize(ByteBuf message) {
+ processHeader(message);
+ final short nwTtl = message.readUnsignedByte();
+ message.skipBytes(ActionConstants.SET_NW_TTL_PADDING);
+
+ return new SetNwTtlActionCaseBuilder()
+ .setSetNwTtlAction(new SetNwTtlActionBuilder()
+ .setNwTtl(nwTtl)
+ .build())
+ .build();
+ }
+
+ @Override
+ public Action deserializeHeader(ByteBuf message) {
+ processHeader(message);
+ return new SetNwTtlActionCaseBuilder().build();
+ }
+
+}
--- /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.deserialization.action;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueActionBuilder;
+
+import io.netty.buffer.ByteBuf;
+
+public class SetQueueActionDeserializer extends AbstractActionDeserializer {
+
+ @Override
+ public Action deserialize(ByteBuf message) {
+ processHeader(message);
+ final long queueId = message.readUnsignedInt();
+
+ return new SetQueueActionCaseBuilder()
+ .setSetQueueAction(new SetQueueActionBuilder()
+ .setQueueId(queueId)
+ .build())
+ .build();
+ }
+
+ @Override
+ public Action deserializeHeader(ByteBuf message) {
+ processHeader(message);
+ return new SetQueueActionCaseBuilder().build();
+ }
+
+}
--- /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.deserialization.action;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCase;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class CopyTtlInActionDeserializerTest extends AbstractActionDeserializerTest {
+
+ @Test
+ public void testDeserialize() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ writeHeader(in);
+ in.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER);
+
+ final Action action = deserializeAction(in);
+ assertTrue(CopyTtlInCase.class.isInstance(action));
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected short getType() {
+ return ActionConstants.COPY_TTL_IN_CODE;
+ }
+
+ @Override
+ protected short getLength() {
+ return ActionConstants.GENERAL_ACTION_LENGTH;
+ }
+
+}
--- /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.deserialization.action;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCase;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class CopyTtlOutActionDeserializerTest extends AbstractActionDeserializerTest {
+
+ @Test
+ public void testDeserialize() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ writeHeader(in);
+ in.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER);
+
+ final Action action = deserializeAction(in);
+ assertTrue(CopyTtlOutCase.class.isInstance(action));
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected short getType() {
+ return ActionConstants.COPY_TTL_OUT_CODE;
+ }
+
+ @Override
+ protected short getLength() {
+ return ActionConstants.GENERAL_ACTION_LENGTH;
+ }
+
+}
--- /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.deserialization.action;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCase;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class DecMplsTtlActionDeserializerTest extends AbstractActionDeserializerTest {
+
+ @Test
+ public void testDeserialize() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ writeHeader(in);
+ in.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER);
+
+ final Action action = deserializeAction(in);
+ assertTrue(DecMplsTtlCase.class.isInstance(action));
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected short getType() {
+ return ActionConstants.DEC_MPLS_TTL_CODE;
+ }
+
+ @Override
+ protected short getLength() {
+ return ActionConstants.GENERAL_ACTION_LENGTH;
+ }
+
+}
--- /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.deserialization.action;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCase;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class DecNwTtlActionDeserializerTest extends AbstractActionDeserializerTest {
+
+ @Test
+ public void testDeserialize() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ writeHeader(in);
+ in.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER);
+
+ final Action action = deserializeAction(in);
+ assertTrue(DecNwTtlCase.class.isInstance(action));
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected short getType() {
+ return ActionConstants.DEC_NW_TTL_CODE;
+ }
+
+ @Override
+ protected short getLength() {
+ return ActionConstants.GENERAL_ACTION_LENGTH;
+ }
+
+}
--- /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.deserialization.action;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class GroupActionDeserializerTest extends AbstractActionDeserializerTest {
+
+ @Test
+ public void testDeserialize() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final int groupId = 10;
+ writeHeader(in);
+ in.writeInt(groupId);
+
+ final Action action = deserializeAction(in);
+ assertTrue(GroupActionCase.class.isInstance(action));
+ assertEquals(groupId, GroupActionCase.class.cast(action).getGroupAction().getGroupId().intValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected short getType() {
+ return ActionConstants.GROUP_CODE;
+ }
+
+ @Override
+ protected short getLength() {
+ return ActionConstants.GENERAL_ACTION_LENGTH;
+ }
+
+}
--- /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.deserialization.action;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputAction;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class OutputActionDeserializerTest extends AbstractActionDeserializerTest {
+
+ @Test
+ public void testDeserialize() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final int portNum = 10;
+ final short maxLength = 24;
+ writeHeader(in);
+ in.writeInt(portNum);
+ in.writeShort(maxLength);
+ in.writeZero(ActionConstants.OUTPUT_PADDING);
+
+ final Action action = deserializeAction(in);
+ assertTrue(OutputActionCase.class.isInstance(action));
+
+ final OutputAction outputAction = OutputActionCase.class.cast(action).getOutputAction();
+ assertEquals(portNum, InventoryDataServiceUtil.portNumberfromNodeConnectorId(
+ OpenflowVersion.OF13, outputAction.getOutputNodeConnector().getValue()).intValue());
+ assertEquals(maxLength, outputAction.getMaxLength().shortValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected short getType() {
+ return ActionConstants.OUTPUT_CODE;
+ }
+
+ @Override
+ protected short getLength() {
+ return ActionConstants.GENERAL_ACTION_LENGTH;
+ }
+
+}
--- /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.deserialization.action;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsAction;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class PopMplsActionDeserializerTest extends AbstractActionDeserializerTest {
+
+ @Test
+ public void testDeserialize() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final short ethType = 10;
+ writeHeader(in);
+ in.writeShort(ethType);
+ in.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING);
+
+ final Action action = deserializeAction(in);
+ assertTrue(PopMplsActionCase.class.isInstance(action));
+
+ final PopMplsAction popAction = PopMplsActionCase.class.cast(action).getPopMplsAction();
+ assertEquals(ethType, popAction.getEthernetType().shortValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected short getType() {
+ return ActionConstants.POP_MPLS_CODE;
+ }
+
+ @Override
+ protected short getLength() {
+ return ActionConstants.GENERAL_ACTION_LENGTH;
+ }
+
+}
--- /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.deserialization.action;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCase;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class PopPbbActionDeserializerTest extends AbstractActionDeserializerTest {
+
+ @Test
+ public void testDeserialize() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ writeHeader(in);
+ in.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER);
+
+ final Action action = deserializeAction(in);
+ assertTrue(PopPbbActionCase.class.isInstance(action));
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected short getType() {
+ return ActionConstants.POP_PBB_CODE;
+ }
+
+ @Override
+ protected short getLength() {
+ return ActionConstants.GENERAL_ACTION_LENGTH;
+ }
+
+}
--- /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.deserialization.action;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCase;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class PopVlanActionDeserializerTest extends AbstractActionDeserializerTest {
+
+ @Test
+ public void testDeserialize() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ writeHeader(in);
+ in.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER);
+
+ final Action action = deserializeAction(in);
+ assertTrue(PopVlanActionCase.class.isInstance(action));
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected short getType() {
+ return ActionConstants.POP_VLAN_CODE;
+ }
+
+ @Override
+ protected short getLength() {
+ return ActionConstants.GENERAL_ACTION_LENGTH;
+ }
+
+}
--- /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.deserialization.action;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCase;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class PushMplsActionDeserializerTest extends AbstractActionDeserializerTest {
+
+ @Test
+ public void testDeserialize() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final short ethType = 10;
+ writeHeader(in);
+ in.writeShort(ethType);
+ in.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING);
+
+ final Action action = deserializeAction(in);
+ assertTrue(PushMplsActionCase.class.isInstance(action));
+ assertEquals(ethType, PushMplsActionCase.class.cast(action).getPushMplsAction().getEthernetType().shortValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected short getType() {
+ return ActionConstants.PUSH_MPLS_CODE;
+ }
+
+ @Override
+ protected short getLength() {
+ return ActionConstants.GENERAL_ACTION_LENGTH;
+ }
+
+}
--- /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.deserialization.action;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCase;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class PushPbbActionDeserializerTest extends AbstractActionDeserializerTest {
+
+ @Test
+ public void testDeserialize() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final short ethType = 10;
+ writeHeader(in);
+ in.writeShort(ethType);
+ in.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING);
+
+ final Action action = deserializeAction(in);
+ assertTrue(PushPbbActionCase.class.isInstance(action));
+ assertEquals(ethType, PushPbbActionCase.class.cast(action).getPushPbbAction().getEthernetType().shortValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected short getType() {
+ return ActionConstants.PUSH_PBB_CODE;
+ }
+
+ @Override
+ protected short getLength() {
+ return ActionConstants.GENERAL_ACTION_LENGTH;
+ }
+
+}
--- /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.deserialization.action;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class PushVlanActionDeserializerTest extends AbstractActionDeserializerTest {
+
+ @Test
+ public void testDeserialize() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final short ethType = 10;
+ writeHeader(in);
+ in.writeShort(ethType);
+ in.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING);
+
+ final Action action = deserializeAction(in);
+ assertTrue(PushVlanActionCase.class.isInstance(action));
+ assertEquals(ethType, PushVlanActionCase.class.cast(action).getPushVlanAction().getEthernetType().shortValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected short getType() {
+ return ActionConstants.PUSH_VLAN_CODE;
+ }
+
+ @Override
+ protected short getLength() {
+ return ActionConstants.GENERAL_ACTION_LENGTH;
+ }
+
+}
--- /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.deserialization.action;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.BinContent;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class SetFieldActionDeserializerTest extends AbstractActionDeserializerTest {
+
+ @Test
+ public void testDeserialize() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final int portNum = 0xfffffffa;
+ writeHeader(in);
+ in.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
+ in.writeByte(OxmMatchConstants.IN_PORT << 1);
+ in.writeByte(EncodeConstants.SIZE_OF_INT_IN_BYTES);
+ in.writeInt(portNum);
+ in.writeZero(EncodeConstants.SIZE_OF_INT_IN_BYTES);
+
+ final Action action = deserializeAction(in);
+ assertTrue(SetFieldCase.class.isInstance(action));
+ assertEquals(
+ OpenflowPortsUtil.getPortLogicalName(EncodeConstants.OF13_VERSION_ID, BinContent.intToUnsignedLong(portNum)),
+ SetFieldCase.class.cast(action).getSetField().getInPort().getValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected short getType() {
+ return ActionConstants.SET_FIELD_CODE;
+ }
+
+ @Override
+ protected short getLength() {
+ return ActionConstants.GENERAL_ACTION_LENGTH;
+ }
+
+}
--- /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.deserialization.action;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCase;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class SetMplsTtlActionDeserializerTest extends AbstractActionDeserializerTest {
+
+ @Test
+ public void testDeserialize() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final short mplsTtl = 10;
+ writeHeader(in);
+ in.writeByte(mplsTtl);
+ in.writeZero(ActionConstants.SET_MPLS_TTL_PADDING);
+
+ final Action action = deserializeAction(in);
+ assertTrue(SetMplsTtlActionCase.class.isInstance(action));
+ assertEquals(mplsTtl, SetMplsTtlActionCase.class.cast(action).getSetMplsTtlAction().getMplsTtl().shortValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected short getType() {
+ return ActionConstants.SET_MPLS_TTL_CODE;
+ }
+
+ @Override
+ protected short getLength() {
+ return ActionConstants.GENERAL_ACTION_LENGTH;
+ }
+
+}
--- /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.deserialization.action;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCase;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class SetNwTtlActionDeserializerTest extends AbstractActionDeserializerTest {
+
+ @Test
+ public void testDeserialize() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final short nwTtl = 10;
+ writeHeader(in);
+ in.writeByte(nwTtl);
+ in.writeZero(ActionConstants.SET_NW_TTL_PADDING);
+
+ final Action action = deserializeAction(in);
+ assertTrue(SetNwTtlActionCase.class.isInstance(action));
+ assertEquals(nwTtl, SetNwTtlActionCase.class.cast(action).getSetNwTtlAction().getNwTtl().shortValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected short getType() {
+ return ActionConstants.SET_NW_TTL_CODE;
+ }
+
+ @Override
+ protected short getLength() {
+ return ActionConstants.GENERAL_ACTION_LENGTH;
+ }
+
+}
--- /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.deserialization.action;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCase;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class SetQueueActionDeserializerTest extends AbstractActionDeserializerTest {
+
+ @Test
+ public void testDeserialize() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final int queueId = 10;
+ writeHeader(in);
+ in.writeInt(queueId);
+
+ final Action action = deserializeAction(in);
+ assertTrue(SetQueueActionCase.class.isInstance(action));
+ assertEquals(queueId, SetQueueActionCase.class.cast(action).getSetQueueAction().getQueueId().intValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected short getType() {
+ return ActionConstants.SET_QUEUE_CODE;
+ }
+
+ @Override
+ protected short getLength() {
+ return ActionConstants.GENERAL_ACTION_LENGTH;
+ }
+
+}