--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10EnqueueActionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10OutputActionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetDlDstActionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetDlSrcActionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetNwDstActionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetNwSrcActionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetNwTosActionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetTpDstActionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetTpSrcActionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetVlanPcpActionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetVlanVidActionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10StripVlanActionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13CopyTtlInActionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13CopyTtlOutActionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13DecMplsTtlActionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13DecNwTtlActionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13GroupActionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13OutputActionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PopMplsActionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PopPbbActionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PopVlanActionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PushMplsActionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PushPbbActionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PushVlanActionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13SetFieldActionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13SetMplsTtlActionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13SetNwTtlActionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13SetQueueActionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.openflowjava.protocol.impl.util.SimpleDeserializerRegistryHelper;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class ActionDeserializerInitializer {\r
+\r
+ /**\r
+ * Registers action deserializers\r
+ * @param registry registry to be filled with deserializers\r
+ */\r
+ public static void registerDeserializers(DeserializerRegistry registry) {\r
+ // register OF v1.0 action deserializers\r
+ SimpleDeserializerRegistryHelper helper =\r
+ new SimpleDeserializerRegistryHelper(EncodeConstants.OF10_VERSION_ID, registry);\r
+ helper.registerDeserializer(0, Action.class, new OF10OutputActionDeserializer());\r
+ helper.registerDeserializer(1, Action.class, new OF10SetVlanVidActionDeserializer());\r
+ helper.registerDeserializer(2, Action.class, new OF10SetVlanPcpActionDeserializer());\r
+ helper.registerDeserializer(3, Action.class, new OF10StripVlanActionDeserializer());\r
+ helper.registerDeserializer(4, Action.class, new OF10SetDlSrcActionDeserializer());\r
+ helper.registerDeserializer(5, Action.class, new OF10SetDlDstActionDeserializer());\r
+ helper.registerDeserializer(6, Action.class, new OF10SetNwSrcActionDeserializer());\r
+ helper.registerDeserializer(7, Action.class, new OF10SetNwDstActionDeserializer());\r
+ helper.registerDeserializer(8, Action.class, new OF10SetNwTosActionDeserializer());\r
+ helper.registerDeserializer(9, Action.class, new OF10SetTpSrcActionDeserializer());\r
+ helper.registerDeserializer(10, Action.class, new OF10SetTpDstActionDeserializer());\r
+ helper.registerDeserializer(11, Action.class, new OF10EnqueueActionDeserializer());\r
+ // register OF v1.3 action deserializers\r
+ helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry);\r
+ helper.registerDeserializer(0, Action.class, new OF13OutputActionDeserializer());\r
+ helper.registerDeserializer(11, Action.class, new OF13CopyTtlOutActionDeserializer());\r
+ helper.registerDeserializer(12, Action.class, new OF13CopyTtlInActionDeserializer());\r
+ helper.registerDeserializer(15, Action.class, new OF13SetMplsTtlActionDeserializer());\r
+ helper.registerDeserializer(16, Action.class, new OF13DecMplsTtlActionDeserializer());\r
+ helper.registerDeserializer(17, Action.class, new OF13PushVlanActionDeserializer());\r
+ helper.registerDeserializer(18, Action.class, new OF13PopVlanActionDeserializer());\r
+ helper.registerDeserializer(19, Action.class, new OF13PushMplsActionDeserializer());\r
+ helper.registerDeserializer(20, Action.class, new OF13PopMplsActionDeserializer());\r
+ helper.registerDeserializer(21, Action.class, new OF13SetQueueActionDeserializer());\r
+ helper.registerDeserializer(22, Action.class, new OF13GroupActionDeserializer());\r
+ helper.registerDeserializer(23, Action.class, new OF13SetNwTtlActionDeserializer());\r
+ helper.registerDeserializer(24, Action.class, new OF13DecNwTtlActionDeserializer());\r
+ helper.registerDeserializer(25, Action.class, new OF13SetFieldActionDeserializer());\r
+ helper.registerDeserializer(26, Action.class, new OF13PushPbbActionDeserializer());\r
+ helper.registerDeserializer(27, Action.class, new OF13PopPbbActionDeserializer());\r
+ }\r
+}\r
package org.opendaylight.openflowjava.protocol.impl.deserialization;\r
\r
import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.experimenters.ExperimenterActionDeserializer;\r
import org.opendaylight.openflowjava.protocol.impl.deserialization.experimenters.OF13ExperimenterInstructionDeserializer;\r
import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.openflowjava.protocol.impl.util.SimpleDeserializerRegistryHelper;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;\r
\r
/**\r
* @param registry registry to be filled with deserializers\r
*/\r
public static void registerDeserializers(DeserializerRegistry registry) {\r
- SimpleDeserializerRegistryHelper helper =\r
- new SimpleDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry);\r
- helper.registerDeserializer(EncodeConstants.EXPERIMENTER_VALUE,\r
- Instruction.class, new OF13ExperimenterInstructionDeserializer());\r
+ // register OF v1.0 default experimenter deserializers\r
+ // - default action deserializer\r
+ registry.registerDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID,\r
+ EncodeConstants.EXPERIMENTER_VALUE, Action.class), new ExperimenterActionDeserializer());\r
+ // register OF v1.3 default experimenter deserializers\r
+ // - default action deserializer\r
+ registry.registerDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID,\r
+ EncodeConstants.EXPERIMENTER_VALUE, Action.class), new ExperimenterActionDeserializer());\r
+ // - default instruction deserializer\r
+ registry.registerDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID,\r
+ EncodeConstants.EXPERIMENTER_VALUE, Instruction.class), new OF13ExperimenterInstructionDeserializer());\r
}\r
}\r
import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer;
-import org.opendaylight.openflowjava.protocol.impl.util.ActionsDeserializer;
import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.openflowjava.protocol.impl.util.MatchDeserializer;
-import org.opendaylight.openflowjava.protocol.impl.util.OF10ActionsDeserializer;
import org.opendaylight.openflowjava.protocol.impl.util.OF10MatchDeserializer;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10;
// register common structure deserializers
registerDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID,
EncodeConstants.EMPTY_VALUE, MatchV10.class), new OF10MatchDeserializer());
- registerDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID,
- EncodeConstants.EMPTY_VALUE, Action.class), new OF10ActionsDeserializer());
registerDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID,
EncodeConstants.EMPTY_VALUE, Match.class), new MatchDeserializer());
- registerDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID,
- EncodeConstants.EMPTY_VALUE, Action.class), new ActionsDeserializer());
// register match entry deserializers
MatchEntryDeserializerInitializer.registerMatchEntryDeserializers(this);
- //register instruction deserializers
+ // register action deserializers
+ ActionDeserializerInitializer.registerDeserializers(this);
+ // register instruction deserializers
InstructionDeserializerInitializer.registerDeserializers(this);
// register default experimenter deserializers
DefaultExperimenterDeserializerInitializer.registerDeserializers(this);
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public abstract class AbstractActionDeserializer implements OFDeserializer<Action>,\r
+ HeaderDeserializer<Action> {\r
+\r
+ @Override\r
+ public Action deserializeHeader(ByteBuf input) {\r
+ ActionBuilder actionBuilder = new ActionBuilder();\r
+ input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ actionBuilder.setType(getType());\r
+ input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ return actionBuilder.build();\r
+ }\r
+\r
+ protected abstract Class<? extends ActionBase> getType();\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public abstract class AbstractEthertypeActionDeserializer extends AbstractActionDeserializer {\r
+\r
+ @Override\r
+ public Action deserialize(ByteBuf input) {\r
+ ActionBuilder builder = new ActionBuilder();\r
+ builder.setType(getType());\r
+ input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ EthertypeActionBuilder etherType = new EthertypeActionBuilder();\r
+ etherType.setEthertype(new EtherType(input.readUnsignedShort()));\r
+ builder.addAugmentation(EthertypeAction.class, etherType.build());\r
+ input.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING);\r
+ return builder.build();\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public abstract class AbstractHeaderActionDeserializer extends AbstractActionDeserializer {\r
+\r
+ @Override\r
+ public Action deserialize(ByteBuf input) {\r
+ ActionBuilder builder = new ActionBuilder();\r
+ input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ builder.setType(getType());\r
+ input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ input.skipBytes(ActionConstants.PADDING_IN_ACTION_HEADER);\r
+ return builder.build();\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;\r
+import org.opendaylight.yangtools.yang.binding.Augmentation;\r
+\r
+import com.google.common.base.Joiner;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public abstract class OF10AbstractIpAddressActionDeserializer extends AbstractActionDeserializer {\r
+\r
+ @Override\r
+ public Action deserialize(ByteBuf input) {\r
+ ActionBuilder builder = new ActionBuilder();\r
+ input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ builder.setType(getType());\r
+ input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ builder.addAugmentation(IpAddressAction.class,\r
+ createNwAddressAugmentationAndPad(input));\r
+ return builder.build();\r
+ }\r
+\r
+ private static Augmentation<Action> createNwAddressAugmentationAndPad(ByteBuf input) {\r
+ IpAddressActionBuilder ipBuilder = new IpAddressActionBuilder();\r
+ List<String> groups = new ArrayList<>();\r
+ for (int i = 0; i < EncodeConstants.GROUPS_IN_IPV4_ADDRESS; i++) {\r
+ groups.add(Short.toString(input.readUnsignedByte()));\r
+ }\r
+ Joiner joiner = Joiner.on(".");\r
+ ipBuilder.setIpAddress(new Ipv4Address(joiner.join(groups)));\r
+ return ipBuilder.build();\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;\r
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public abstract class OF10AbstractMacAddressActionDeserializer extends AbstractActionDeserializer {\r
+\r
+ @Override\r
+ public Action deserialize(ByteBuf input) {\r
+ ActionBuilder builder = new ActionBuilder();\r
+ input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ builder.setType(getType());\r
+ input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ builder.addAugmentation(DlAddressAction.class, createDlAugmentationAndPad(input));\r
+ return builder.build();\r
+ }\r
+\r
+ private static DlAddressAction createDlAugmentationAndPad(ByteBuf input) {\r
+ DlAddressActionBuilder dlBuilder = new DlAddressActionBuilder();\r
+ byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];\r
+ input.readBytes(address);\r
+ dlBuilder.setDlAddress(new MacAddress(ByteBufUtils.macAddressToString(address)));\r
+ input.skipBytes(ActionConstants.PADDING_IN_DL_ADDRESS_ACTION);\r
+ return dlBuilder.build();\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public abstract class OF10AbstractPortActionDeserializer extends AbstractActionDeserializer {\r
+\r
+ @Override\r
+ public Action deserialize(ByteBuf input) {\r
+ ActionBuilder builder = new ActionBuilder();\r
+ input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ builder.setType(getType());\r
+ input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ createPortAugmentation(input, builder);\r
+ input.skipBytes(ActionConstants.PADDING_IN_TP_PORT_ACTION);\r
+ return builder.build();\r
+ }\r
+\r
+ protected static void createPortAugmentation(ByteBuf input, ActionBuilder actionBuilder) {\r
+ PortActionBuilder portBuilder = new PortActionBuilder();\r
+ portBuilder.setPort(new PortNumber((long) input.readUnsignedShort()));\r
+ actionBuilder.addAugmentation(PortAction.class, portBuilder.build());\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Enqueue;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OF10EnqueueActionDeserializer extends OF10AbstractPortActionDeserializer {\r
+\r
+ @Override\r
+ public Action deserialize(ByteBuf input) {\r
+ ActionBuilder builder = new ActionBuilder();\r
+ input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ builder.setType(getType());\r
+ input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ createPortAugmentation(input, builder);\r
+ input.skipBytes(ActionConstants.PADDING_IN_ENQUEUE_ACTION);\r
+ QueueIdActionBuilder queueBuilder = new QueueIdActionBuilder();\r
+ queueBuilder.setQueueId(input.readUnsignedInt());\r
+ builder.addAugmentation(QueueIdAction.class, queueBuilder.build());\r
+ return builder.build();\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends ActionBase> getType() {\r
+ return Enqueue.class;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OF10OutputActionDeserializer extends OF10AbstractPortActionDeserializer {\r
+\r
+ @Override\r
+ public Action deserialize(ByteBuf input) {\r
+ ActionBuilder builder = new ActionBuilder();\r
+ input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ builder.setType(getType());\r
+ input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ createPortAugmentation(input, builder);\r
+ MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder();\r
+ maxLen.setMaxLength(input.readUnsignedShort());\r
+ builder.addAugmentation(MaxLengthAction.class, maxLen.build());\r
+ return builder.build();\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends ActionBase> getType() {\r
+ return Output.class;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlDst;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OF10SetDlDstActionDeserializer extends OF10AbstractMacAddressActionDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends ActionBase> getType() {\r
+ return SetDlDst.class;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlSrc;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OF10SetDlSrcActionDeserializer extends OF10AbstractMacAddressActionDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends ActionBase> getType() {\r
+ return SetDlSrc.class;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwDst;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OF10SetNwDstActionDeserializer extends OF10AbstractIpAddressActionDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends ActionBase> getType() {\r
+ return SetNwDst.class;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwSrc;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OF10SetNwSrcActionDeserializer extends OF10AbstractIpAddressActionDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends ActionBase> getType() {\r
+ return SetNwSrc.class;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosAction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTos;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OF10SetNwTosActionDeserializer extends AbstractActionDeserializer {\r
+\r
+ @Override\r
+ public Action deserialize(ByteBuf input) {\r
+ ActionBuilder builder = new ActionBuilder();\r
+ input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ builder.setType(getType());\r
+ input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ NwTosActionBuilder tosBuilder = new NwTosActionBuilder();\r
+ tosBuilder.setNwTos(input.readUnsignedByte());\r
+ builder.addAugmentation(NwTosAction.class, tosBuilder.build());\r
+ input.skipBytes(ActionConstants.PADDING_IN_SET_NW_TOS_ACTION);\r
+ return builder.build();\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends ActionBase> getType() {\r
+ return SetNwTos.class;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpDst;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OF10SetTpDstActionDeserializer extends OF10AbstractPortActionDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends ActionBase> getType() {\r
+ return SetTpDst.class;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpSrc;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OF10SetTpSrcActionDeserializer extends OF10AbstractPortActionDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends ActionBase> getType() {\r
+ return SetTpSrc.class;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpAction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanPcp;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OF10SetVlanPcpActionDeserializer extends AbstractActionDeserializer {\r
+\r
+ @Override\r
+ public Action deserialize(ByteBuf input) {\r
+ ActionBuilder builder = new ActionBuilder();\r
+ input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ builder.setType(getType());\r
+ input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ VlanPcpActionBuilder vlanBuilder = new VlanPcpActionBuilder();\r
+ vlanBuilder.setVlanPcp(input.readUnsignedByte());\r
+ input.skipBytes(ActionConstants.PADDING_IN_SET_VLAN_PCP_ACTION);\r
+ builder.addAugmentation(VlanPcpAction.class, vlanBuilder.build());\r
+ return builder.build();\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends ActionBase> getType() {\r
+ return SetVlanPcp.class;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OF10SetVlanVidActionDeserializer extends AbstractActionDeserializer {\r
+\r
+ @Override\r
+ public Action deserialize(ByteBuf input) {\r
+ ActionBuilder builder = new ActionBuilder();\r
+ input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ builder.setType(getType());\r
+ input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ VlanVidActionBuilder vlanBuilder = new VlanVidActionBuilder();\r
+ vlanBuilder.setVlanVid(input.readUnsignedShort());\r
+ input.skipBytes(ActionConstants.PADDING_IN_SET_VLAN_VID_ACTION);\r
+ builder.addAugmentation(VlanVidAction.class, vlanBuilder.build());\r
+ return builder.build();\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends ActionBase> getType() {\r
+ return SetVlanVid.class;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OF10StripVlanActionDeserializer extends AbstractHeaderActionDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends ActionBase> getType() {\r
+ return StripVlan.class;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OF13CopyTtlInActionDeserializer extends AbstractHeaderActionDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends ActionBase> getType() {\r
+ return CopyTtlIn.class;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OF13CopyTtlOutActionDeserializer extends AbstractHeaderActionDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends ActionBase> getType() {\r
+ return CopyTtlOut.class;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OF13DecMplsTtlActionDeserializer extends AbstractHeaderActionDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends ActionBase> getType() {\r
+ return DecMplsTtl.class;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OF13DecNwTtlActionDeserializer extends AbstractHeaderActionDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends ActionBase> getType() {\r
+ return DecNwTtl.class;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OF13GroupActionDeserializer extends AbstractActionDeserializer {\r
+\r
+ @Override\r
+ public Action deserialize(ByteBuf input) {\r
+ ActionBuilder builder = new ActionBuilder();\r
+ builder.setType(getType());\r
+ input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ GroupIdActionBuilder group = new GroupIdActionBuilder();\r
+ group.setGroupId(input.readUnsignedInt());\r
+ builder.addAugmentation(GroupIdAction.class, group.build());\r
+ return builder.build();\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends ActionBase> getType() {\r
+ return Group.class;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OF13OutputActionDeserializer extends AbstractActionDeserializer {\r
+\r
+ @Override\r
+ public Action deserialize(ByteBuf input) {\r
+ ActionBuilder builder = new ActionBuilder();\r
+ builder.setType(getType());\r
+ input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ PortActionBuilder port = new PortActionBuilder();\r
+ port.setPort(new PortNumber(input.readUnsignedInt()));\r
+ builder.addAugmentation(PortAction.class, port.build());\r
+ MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder();\r
+ maxLen.setMaxLength(input.readUnsignedShort());\r
+ builder.addAugmentation(MaxLengthAction.class, maxLen.build());\r
+ input.skipBytes(ActionConstants.OUTPUT_PADDING);\r
+ return builder.build();\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends ActionBase> getType() {\r
+ return Output.class;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OF13PopMplsActionDeserializer extends AbstractEthertypeActionDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends ActionBase> getType() {\r
+ return PopMpls.class;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OF13PopPbbActionDeserializer extends AbstractHeaderActionDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends ActionBase> getType() {\r
+ return PopPbb.class;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OF13PopVlanActionDeserializer extends AbstractHeaderActionDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends ActionBase> getType() {\r
+ return PopVlan.class;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OF13PushMplsActionDeserializer extends AbstractEthertypeActionDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends ActionBase> getType() {\r
+ return PushMpls.class;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OF13PushPbbActionDeserializer extends AbstractEthertypeActionDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends ActionBase> getType() {\r
+ return PushPbb.class;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OF13PushVlanActionDeserializer extends AbstractEthertypeActionDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends ActionBase> getType() {\r
+ return PushVlan.class;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.EnhancedMessageCodeKey;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OF13SetFieldActionDeserializer extends AbstractActionDeserializer\r
+ implements DeserializerRegistryInjector {\r
+\r
+ private DeserializerRegistry registry;\r
+\r
+ @Override\r
+ public Action deserialize(ByteBuf input) {\r
+ ActionBuilder builder = new ActionBuilder();\r
+ builder.setType(getType());\r
+ int startIndex = input.readerIndex();\r
+ input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ OxmFieldsActionBuilder matchEntries = new OxmFieldsActionBuilder();\r
+ int oxmClass = input.getUnsignedShort(input.readerIndex());\r
+ // get oxm_field & hasMask byte and extract the field value\r
+ int oxmField = input.getUnsignedByte(input.readerIndex()\r
+ + EncodeConstants.SIZE_OF_SHORT_IN_BYTES) >>> 1;\r
+ OFDeserializer<MatchEntries> matchDeserializer = registry.getDeserializer(\r
+ new EnhancedMessageCodeKey(EncodeConstants.OF13_VERSION_ID, oxmClass,\r
+ oxmField, MatchEntries.class));\r
+ List<MatchEntries> entry = new ArrayList<>();\r
+ entry.add(matchDeserializer.deserialize(input));\r
+ matchEntries.setMatchEntries(entry);\r
+ builder.addAugmentation(OxmFieldsAction.class, matchEntries.build());\r
+ int paddingRemainder = (input.readerIndex() - startIndex) % EncodeConstants.PADDING;\r
+ if (paddingRemainder != 0) {\r
+ input.skipBytes(EncodeConstants.PADDING - paddingRemainder);\r
+ }\r
+ return builder.build();\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends ActionBase> getType() {\r
+ return SetField.class;\r
+ }\r
+\r
+ @Override\r
+ public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) {\r
+ this.registry = deserializerRegistry;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OF13SetMplsTtlActionDeserializer extends AbstractActionDeserializer {\r
+\r
+ @Override\r
+ public Action deserialize(ByteBuf input) {\r
+ ActionBuilder builder = new ActionBuilder();\r
+ builder.setType(getType());\r
+ input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ MplsTtlActionBuilder mplsTtl = new MplsTtlActionBuilder();\r
+ mplsTtl.setMplsTtl(input.readUnsignedByte());\r
+ builder.addAugmentation(MplsTtlAction.class, mplsTtl.build());\r
+ input.skipBytes(ActionConstants.SET_MPLS_TTL_PADDING);\r
+ return builder.build();\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends ActionBase> getType() {\r
+ return SetMplsTtl.class;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OF13SetNwTtlActionDeserializer extends AbstractActionDeserializer {\r
+\r
+ @Override\r
+ public Action deserialize(ByteBuf input) {\r
+ ActionBuilder builder = new ActionBuilder();\r
+ builder.setType(getType());\r
+ input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ NwTtlActionBuilder nwTtl = new NwTtlActionBuilder();\r
+ nwTtl.setNwTtl(input.readUnsignedByte());\r
+ builder.addAugmentation(NwTtlAction.class, nwTtl.build());\r
+ input.skipBytes(ActionConstants.SET_NW_TTL_PADDING);\r
+ return builder.build();\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends ActionBase> getType() {\r
+ return SetNwTtl.class;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OF13SetQueueActionDeserializer extends AbstractActionDeserializer {\r
+\r
+ @Override\r
+ public Action deserialize(ByteBuf input) {\r
+ ActionBuilder builder = new ActionBuilder();\r
+ builder.setType(getType());\r
+ input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ QueueIdActionBuilder queueId = new QueueIdActionBuilder();\r
+ queueId.setQueueId(input.readUnsignedInt());\r
+ builder.addAugmentation(QueueIdAction.class, queueId.build());\r
+ return builder.build();\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends ActionBase> getType() {\r
+ return SetQueue.class;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.experimenters;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class ExperimenterActionDeserializer implements OFDeserializer<Action>,\r
+ HeaderDeserializer<Action> {\r
+\r
+ @Override\r
+ public Action deserializeHeader(ByteBuf input) {\r
+ ActionBuilder builder = new ActionBuilder();\r
+ input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ builder.setType(Experimenter.class);\r
+ input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder();\r
+ expBuilder.setExperimenter(input.readUnsignedInt());\r
+ builder.addAugmentation(ExperimenterAction.class, expBuilder.build());\r
+ return builder.build();\r
+ }\r
+\r
+ @Override\r
+ public Action deserialize(ByteBuf input) {\r
+ ActionBuilder builder = new ActionBuilder();\r
+ input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ builder.setType(Experimenter.class);\r
+ int length = input.readUnsignedShort();\r
+ // subtract experimenter header length\r
+ length -= EncodeConstants.EXPERIMENTER_IDS_LENGTH;\r
+ ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder();\r
+ expBuilder.setExperimenter(input.readUnsignedInt());\r
+ if (length > 0) {\r
+ byte[] data = new byte[length];\r
+ input.readBytes(data);\r
+ expBuilder.setData(data);\r
+ }\r
+ builder.addAugmentation(ExperimenterAction.class, expBuilder.build());\r
+ return builder.build();\r
+ }\r
+\r
+}\r
+++ /dev/null
-/*
- * Copyright (c) 2013 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.openflowjava.protocol.impl.util;
-
-import io.netty.buffer.ByteBuf;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
-import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
-import org.opendaylight.openflowjava.protocol.api.extensibility.EnhancedMessageCodeKey;
-import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;
-import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
-import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
-
-/**
- * Deserializes ofp_actions (OpenFlow v1.3)
- * @author timotej.kubas
- * @author michal.polkorab
- */
-public class ActionsDeserializer implements OFDeserializer<Action>,
- HeaderDeserializer<Action>, DeserializerRegistryInjector {
-
- private static final byte PADDING_IN_ACTIONS_HEADER = 4;
- private static final byte PADDING_IN_OUTPUT_ACTIONS_HEADER = 6;
- private static final byte PADDING_IN_SET_MPLS_TTL_ACTIONS_HEADER = 3;
- private static final byte PADDING_IN_PUSH_VLAN_ACTIONS_HEADER = 2;
- private static final byte PADDING_IN_NW_TTL_ACTIONS_HEADER = 3;
- private DeserializerRegistry registry;
-
- @Override
- public Action deserialize(ByteBuf input) {
- Action action = null;
- ActionBuilder actionBuilder = new ActionBuilder();
- int type = input.getUnsignedShort(input.readerIndex());
- switch(type) {
- case 0:
- action = createOutputAction(input, actionBuilder);
- break;
- case 11:
- action = createCopyTtlOutAction(input, actionBuilder);
- break;
- case 12:
- action = createCopyTtlInAction(input, actionBuilder);
- break;
- case 15:
- action = createSetMplsTtlAction(input, actionBuilder);
- break;
- case 16:
- action = createDecMplsTtlOutAction(input, actionBuilder);
- break;
- case 17:
- action = createPushVlanAction(input, actionBuilder);
- break;
- case 18:
- action = createPopVlanAction(input, actionBuilder);
- break;
- case 19:
- action = createPushMplsAction(input, actionBuilder);
- break;
- case 20:
- action = createPopMplsAction(input, actionBuilder);
- break;
- case 21:
- action = createSetQueueAction(input, actionBuilder);
- break;
- case 22:
- action = createGroupAction(input, actionBuilder);
- break;
- case 23:
- action = createSetNwTtlAction(input, actionBuilder);
- break;
- case 24:
- action = createDecNwTtlAction(input, actionBuilder);
- break;
- case 25:
- action = createSetFieldAction(input, actionBuilder);
- break;
- case 26:
- action = createPushPbbAction(input, actionBuilder);
- break;
- case 27:
- action = createPopPbbAction(input, actionBuilder);
- break;
- case 0xFFFF:
- OFDeserializer<ExperimenterAction> expDeserializer = registry.getDeserializer(
- new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 0xFFFF, ExperimenterAction.class));
- ExperimenterAction expAction = expDeserializer.deserialize(input);
- actionBuilder.addAugmentation(ExperimenterAction.class, expAction);
- break;
- default:
- break;
- }
- return action;
- }
-
- @Override
- public Action deserializeHeader(ByteBuf input) {
- ActionBuilder builder;
- builder = new ActionBuilder();
- int type = input.readUnsignedShort();
- input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
- switch(type) {
- case 0:
- builder.setType(Output.class);
- break;
- case 11:
- builder.setType(CopyTtlOut.class);
- break;
- case 12:
- builder.setType(CopyTtlIn.class);
- break;
- case 15:
- builder.setType(SetMplsTtl.class);
- break;
- case 16:
- builder.setType(DecMplsTtl.class);
- break;
- case 17:
- builder.setType(PushVlan.class);
- break;
- case 18:
- builder.setType(PopVlan.class);
- break;
- case 19:
- builder.setType(PushMpls.class);
- break;
- case 20:
- builder.setType(PopMpls.class);
- break;
- case 21:
- builder.setType(SetQueue.class);
- break;
- case 22:
- builder.setType(Group.class);
- break;
- case 23:
- builder.setType(SetNwTtl.class);
- break;
- case 24:
- builder.setType(DecNwTtl.class);
- break;
- case 25:
- builder.setType(SetField.class);
- break;
- case 26:
- builder.setType(PushPbb.class);
- break;
- case 27:
- builder.setType(PopPbb.class);
- break;
- case 0xFFFF:
- HeaderDeserializer<ExperimenterAction> expDeserializer = registry.getDeserializer(
- new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 0xFFFF, ExperimenterAction.class));
- ExperimenterAction expAction = expDeserializer.deserializeHeader(input);
- builder.setType(Experimenter.class);
- builder.addAugmentation(ExperimenterAction.class, expAction);
- break;
- default:
- break;
- }
- return builder.build();
- }
-
- private static Action createEmptyHeader(Class<? extends ActionBase> action,
- ByteBuf in, ActionBuilder actionBuilder) {
- actionBuilder.setType(action);
- in.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
- in.skipBytes(PADDING_IN_ACTIONS_HEADER);
- return actionBuilder.build();
- }
-
- private static Action createCopyTtlInAction(ByteBuf in, ActionBuilder actionBuilder) {
- return createEmptyHeader(CopyTtlIn.class, in, actionBuilder);
- }
-
- private static Action createCopyTtlOutAction(ByteBuf in, ActionBuilder actionBuilder) {
- return createEmptyHeader(CopyTtlOut.class, in, actionBuilder);
- }
-
- private static Action createDecMplsTtlOutAction(ByteBuf in, ActionBuilder actionBuilder) {
- return createEmptyHeader(DecMplsTtl.class, in, actionBuilder);
- }
-
- private static Action createPopVlanAction(ByteBuf in, ActionBuilder actionBuilder) {
- return createEmptyHeader(PopVlan.class, in, actionBuilder);
- }
-
- private static Action createDecNwTtlAction(ByteBuf in, ActionBuilder actionBuilder) {
- return createEmptyHeader(DecNwTtl.class, in, actionBuilder);
- }
-
- private static Action createPopPbbAction(ByteBuf in, ActionBuilder actionBuilder) {
- return createEmptyHeader(PopPbb.class, in, actionBuilder);
- }
-
- private static Action createOutputAction(ByteBuf in, ActionBuilder actionBuilder) {
- actionBuilder.setType(Output.class);
- in.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
- PortActionBuilder port = new PortActionBuilder();
- port.setPort(new PortNumber(in.readUnsignedInt()));
- actionBuilder.addAugmentation(PortAction.class, port.build());
- MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder();
- maxLen.setMaxLength(in.readUnsignedShort());
- actionBuilder.addAugmentation(MaxLengthAction.class, maxLen.build());
- in.skipBytes(PADDING_IN_OUTPUT_ACTIONS_HEADER);
- return actionBuilder.build();
- }
-
- private static Action createSetMplsTtlAction(ByteBuf in, ActionBuilder actionBuilder) {
- actionBuilder.setType(SetMplsTtl.class);
- in.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
- MplsTtlActionBuilder mplsTtl = new MplsTtlActionBuilder();
- mplsTtl.setMplsTtl(in.readUnsignedByte());
- actionBuilder.addAugmentation(MplsTtlAction.class, mplsTtl.build());
- in.skipBytes(PADDING_IN_SET_MPLS_TTL_ACTIONS_HEADER);
- return actionBuilder.build();
- }
-
- private static Action createPushAction(Class<? extends ActionBase> action,
- ByteBuf in, ActionBuilder actionBuilder) {
- actionBuilder.setType(action);
- in.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
- EthertypeActionBuilder etherType = new EthertypeActionBuilder();
- etherType.setEthertype(new EtherType(in.readUnsignedShort()));
- actionBuilder.addAugmentation(EthertypeAction.class, etherType.build());
- in.skipBytes(PADDING_IN_PUSH_VLAN_ACTIONS_HEADER);
- return actionBuilder.build();
- }
-
- private static Action createPushVlanAction(ByteBuf in, ActionBuilder actionBuilder) {
- return createPushAction(PushVlan.class, in, actionBuilder);
- }
-
- private static Action createPushMplsAction(ByteBuf in, ActionBuilder actionBuilder) {
- return createPushAction(PushMpls.class, in, actionBuilder);
- }
-
- private static Action createPopMplsAction(ByteBuf in, ActionBuilder actionBuilder) {
- return createPushAction(PopMpls.class, in, actionBuilder);
- }
-
- private static Action createPushPbbAction(ByteBuf in, ActionBuilder actionBuilder) {
- return createPushAction(PushPbb.class, in, actionBuilder);
- }
-
- private static Action createSetQueueAction(ByteBuf in, ActionBuilder actionBuilder) {
- actionBuilder.setType(SetQueue.class);
- in.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
- QueueIdActionBuilder queueId = new QueueIdActionBuilder();
- queueId.setQueueId(in.readUnsignedInt());
- actionBuilder.addAugmentation(QueueIdAction.class, queueId.build());
- return actionBuilder.build();
- }
-
- private static Action createGroupAction(ByteBuf in, ActionBuilder actionBuilder) {
- actionBuilder.setType(Group.class);
- in.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
- GroupIdActionBuilder group = new GroupIdActionBuilder();
- group.setGroupId(in.readUnsignedInt());
- actionBuilder.addAugmentation(GroupIdAction.class, group.build());
- return actionBuilder.build();
- }
-
- private static Action createSetNwTtlAction(ByteBuf in, ActionBuilder actionBuilder) {
- actionBuilder.setType(SetNwTtl.class);
- in.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
- NwTtlActionBuilder nwTtl = new NwTtlActionBuilder();
- nwTtl.setNwTtl(in.readUnsignedByte());
- actionBuilder.addAugmentation(NwTtlAction.class, nwTtl.build());
- in.skipBytes(PADDING_IN_NW_TTL_ACTIONS_HEADER);
- return actionBuilder.build();
- }
-
- private Action createSetFieldAction(ByteBuf in, ActionBuilder actionBuilder) {
- actionBuilder.setType(SetField.class);
- int startIndex = in.readerIndex();
- in.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
- OxmFieldsActionBuilder matchEntries = new OxmFieldsActionBuilder();
- int oxmClass = in.getUnsignedShort(in.readerIndex());
- // get oxm_field & hasMask byte and extract the field value
- int oxmField = in.getUnsignedByte(in.readerIndex()
- + EncodeConstants.SIZE_OF_SHORT_IN_BYTES) >>> 1;
- OFDeserializer<MatchEntries> matchDeserializer = registry.getDeserializer(
- new EnhancedMessageCodeKey(EncodeConstants.OF13_VERSION_ID, oxmClass,
- oxmField, MatchEntries.class));
- List<MatchEntries> entry = new ArrayList<>();
- entry.add(matchDeserializer.deserialize(in));
- matchEntries.setMatchEntries(entry);
- actionBuilder.addAugmentation(OxmFieldsAction.class, matchEntries.build());
- int paddingRemainder = (in.readerIndex() - startIndex) % EncodeConstants.PADDING;
- if (paddingRemainder != 0) {
- in.skipBytes(EncodeConstants.PADDING - paddingRemainder);
- }
- return actionBuilder.build();
- }
-
- @Override
- public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) {
- registry = deserializerRegistry;
- }
-}
return new AbstractCodeKeyMaker(version) {\r
@Override\r
public MessageCodeKey make(ByteBuf input) {\r
- // EncodeConstants.EMPTY_VALUE used as temporary value\r
- // until action deserializers are split\r
-// int type = input.getUnsignedShort(input.readerIndex());\r
-// return new MessageCodeKey(getVersion(), type, Action.class);\r
- return new MessageCodeKey(getVersion(), EncodeConstants.EMPTY_VALUE, Action.class);\r
+ int type = input.getUnsignedShort(input.readerIndex());\r
+ return new MessageCodeKey(getVersion(), type, Action.class);\r
}\r
};\r
}\r
+++ /dev/null
-/*
- * Copyright (c) 2013 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.openflowjava.protocol.impl.util;
-
-import io.netty.buffer.ByteBuf;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
-import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
-import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
-import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Enqueue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlDst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlSrc;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwDst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwSrc;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTos;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpDst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpSrc;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanPcp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
-import org.opendaylight.yangtools.yang.binding.Augmentation;
-
-import com.google.common.base.Joiner;
-
-/**
- * Deserializes ofp_action (OpenFlow v1.0) structures
- * @author michal.polkorab
- */
-public class OF10ActionsDeserializer implements OFDeserializer<Action>,
- DeserializerRegistryInjector {
-
- private static final byte PADDING_IN_SET_VLAN_VID_ACTION = 2;
- private static final byte PADDING_IN_SET_VLAN_PCP_ACTION = 3;
- private static final byte PADDING_IN_STRIP_VLAN_ACTION = 4;
- private static final byte PADDING_IN_SET_DL_ACTION = 6;
- private static final byte PADDING_IN_NW_TOS_ACTION = 3;
- private static final byte PADDING_IN_TP_ACTION = 2;
- private static final byte PADDING_IN_ENQUEUE_ACTION = 6;
- private DeserializerRegistry registry;
-
- @Override
- public Action deserialize(ByteBuf input) {
- int type = input.readUnsignedShort();
- input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
- ActionBuilder actionsBuilder = new ActionBuilder();
- Action actionsList = null;
- switch(type) {
- case 0:
- actionsList = createOutputAction(input, actionsBuilder);
- break;
- case 1:
- actionsList = createSetVlanVidAction(input, actionsBuilder);
- break;
- case 2:
- actionsList = createVlanPcpAction(input, actionsBuilder);
- break;
- case 3:
- actionsList = createStripVlanAction(input, actionsBuilder);
- break;
- case 4:
- actionsList = createSetDlSrcAction(input, actionsBuilder);
- break;
- case 5:
- actionsList = createSetDlDstAction(input, actionsBuilder);
- break;
- case 6:
- actionsList = createSetNwSrcAction(input, actionsBuilder);
- break;
- case 7:
- actionsList = createSetNwDstAction(input, actionsBuilder);
- break;
- case 8:
- actionsList = createSetNwTosAction(input, actionsBuilder);
- break;
- case 9:
- actionsList = createSetTpSrcAction(input, actionsBuilder);
- break;
- case 10:
- actionsList = createSetTpDstAction(input, actionsBuilder);
- break;
- case 11:
- actionsList = createEnqueueAction(input, actionsBuilder);
- break;
- case 0xFFFF:
- OFDeserializer<ExperimenterAction> expDeserializer = registry.getDeserializer(
- new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 0xFFFF, ExperimenterAction.class));
- expDeserializer.deserialize(input);
- break;
- default:
- break;
- }
- return actionsList;
- }
-
- /**
- * @param in input ByteBuf
- * @param builder
- * @return ActionList
- */
- public static Action createOutputAction(ByteBuf in, ActionBuilder builder) {
- builder.setType(Output.class);
- createPortAugmentation(in, builder);
- MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder();
- maxLen.setMaxLength(in.readUnsignedShort());
- builder.addAugmentation(MaxLengthAction.class, maxLen.build());
- return builder.build();
- }
-
- private static Action createSetVlanVidAction(ByteBuf input, ActionBuilder builder) {
- builder.setType(SetVlanVid.class);
- VlanVidActionBuilder vlanBuilder = new VlanVidActionBuilder();
- vlanBuilder.setVlanVid(input.readUnsignedShort());
- input.skipBytes(PADDING_IN_SET_VLAN_VID_ACTION);
- builder.addAugmentation(VlanVidAction.class, vlanBuilder.build());
- return builder.build();
- }
-
- private static Action createVlanPcpAction(ByteBuf input, ActionBuilder builder) {
- builder.setType(SetVlanPcp.class);
- VlanPcpActionBuilder vlanBuilder = new VlanPcpActionBuilder();
- vlanBuilder.setVlanPcp(input.readUnsignedByte());
- input.skipBytes(PADDING_IN_SET_VLAN_PCP_ACTION);
- builder.addAugmentation(VlanPcpAction.class, vlanBuilder.build());
- return builder.build();
- }
-
- private static Action createStripVlanAction(ByteBuf input, ActionBuilder builder) {
- builder.setType(StripVlan.class);
- input.skipBytes(PADDING_IN_STRIP_VLAN_ACTION);
- return builder.build();
- }
-
- private static Action createSetDlSrcAction(ByteBuf input, ActionBuilder builder) {
- builder.setType(SetDlSrc.class);
- builder.addAugmentation(DlAddressAction.class, createDlAugmentationAndPad(input));
- return builder.build();
- }
-
- private static Action createSetDlDstAction(ByteBuf input, ActionBuilder builder) {
- builder.setType(SetDlDst.class);
- builder.addAugmentation(DlAddressAction.class, createDlAugmentationAndPad(input));
- return builder.build();
- }
-
- private static DlAddressAction createDlAugmentationAndPad(ByteBuf input) {
- DlAddressActionBuilder dlBuilder = new DlAddressActionBuilder();
- byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];
- input.readBytes(address);
- dlBuilder.setDlAddress(new MacAddress(ByteBufUtils.macAddressToString(address)));
- input.skipBytes(PADDING_IN_SET_DL_ACTION);
- return dlBuilder.build();
- }
-
- private static Action createSetNwSrcAction(ByteBuf input, ActionBuilder builder) {
- builder.setType(SetNwSrc.class);
- builder.addAugmentation(IpAddressAction.class, createNwAddressAugmentationAndPad(input));
- return builder.build();
- }
-
- private static Action createSetNwDstAction(ByteBuf input, ActionBuilder builder) {
- builder.setType(SetNwDst.class);
- builder.addAugmentation(IpAddressAction.class, createNwAddressAugmentationAndPad(input));
- return builder.build();
- }
-
- private static Augmentation<Action> createNwAddressAugmentationAndPad(ByteBuf input) {
- IpAddressActionBuilder ipBuilder = new IpAddressActionBuilder();
- List<String> groups = new ArrayList<>();
- for (int i = 0; i < EncodeConstants.GROUPS_IN_IPV4_ADDRESS; i++) {
- groups.add(Short.toString(input.readUnsignedByte()));
- }
- Joiner joiner = Joiner.on(".");
- ipBuilder.setIpAddress(new Ipv4Address(joiner.join(groups)));
- return ipBuilder.build();
- }
-
- private static Action createSetNwTosAction(ByteBuf input, ActionBuilder builder) {
- builder.setType(SetNwTos.class);
- NwTosActionBuilder tosBuilder = new NwTosActionBuilder();
- tosBuilder.setNwTos(input.readUnsignedByte());
- builder.addAugmentation(NwTosAction.class, tosBuilder.build());
- input.skipBytes(PADDING_IN_NW_TOS_ACTION);
- return builder.build();
- }
-
- private static Action createSetTpSrcAction(ByteBuf input, ActionBuilder builder) {
- builder.setType(SetTpSrc.class);
- createPortAugmentation(input, builder);
- input.skipBytes(PADDING_IN_TP_ACTION);
- return builder.build();
- }
-
- private static Action createSetTpDstAction(ByteBuf input, ActionBuilder builder) {
- builder.setType(SetTpDst.class);
- createPortAugmentation(input, builder);
- input.skipBytes(PADDING_IN_TP_ACTION);
- return builder.build();
- }
-
- private static void createPortAugmentation(ByteBuf input, ActionBuilder actionBuilder) {
- PortActionBuilder portBuilder = new PortActionBuilder();
- portBuilder.setPort(new PortNumber((long) input.readUnsignedShort()));
- actionBuilder.addAugmentation(PortAction.class, portBuilder.build());
- }
-
- private static Action createEnqueueAction(ByteBuf input, ActionBuilder builder) {
- builder.setType(Enqueue.class);
- createPortAugmentation(input, builder);
- input.skipBytes(PADDING_IN_ENQUEUE_ACTION);
- QueueIdActionBuilder queueBuilder = new QueueIdActionBuilder();
- queueBuilder.setQueueId(input.readUnsignedInt());
- builder.addAugmentation(QueueIdAction.class, queueBuilder.build());
- return builder.build();
- }
-
- @Override
- public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) {
- registry = deserializerRegistry;
- }
-}