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.SetQueue;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.action.header.ActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.AnyPortNumber;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsList;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsListBuilder;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.bucket.ActionsList;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.bucket.ActionsListBuilder;\r
\r
/**\r
- * Class for easy creation of actions\r
+ * Class for easy deserialization of actions\r
* \r
* @author timotej.kubas\r
* @author michal.polkorab\r
*/\r
-public abstract class ActionCreator {\r
+public abstract class ActionsDeserializer {\r
final static byte PAD_ACTION_LENGTH = 2;\r
private static ActionBuilder actionBuilder = new ActionBuilder();\r
private static ActionsListBuilder actionsListBuilder = new ActionsListBuilder();\r
private static List<ActionsList> actionsList = new ArrayList<>();\r
-/**\r
- * @param inp input ByteBuf\r
- * @param bucketsLength length of buckets\r
- * @return ActionsList\r
- */\r
- public static List<ActionsList> createActionsList(ByteBuf inp, int bucketsLength) {\r
+ \r
+ /**\r
+ * @param input input ByteBuf\r
+ * @param bucketsLength length of buckets\r
+ * @return ActionsList\r
+ */\r
+ public static List<ActionsList> createActionsList(ByteBuf input, int bucketsLength) {\r
final byte BUCKET_HEADER_LENGTH = 16;\r
int bucketsCurrentLength = BUCKET_HEADER_LENGTH;\r
int actionsLength = 0;\r
\r
while (bucketsCurrentLength < bucketsLength) {\r
- switch(inp.readUnsignedShort()) {\r
- case 0: actionsLength = inp.readUnsignedShort(); //outputActionLength\r
- actionsList.add(ActionCreator.createOutputAction(inp));\r
- bucketsCurrentLength = bucketsCurrentLength + actionsLength;\r
+ switch(input.readUnsignedShort()) {\r
+ case 0: actionsLength = input.readUnsignedShort(); //outputActionLength\r
+ actionsList.add(ActionsDeserializer.createOutputAction(input));\r
break;\r
case 11: \r
- actionsLength = inp.readUnsignedShort();//empty header length\r
- actionsList.add(ActionCreator.createCopyTtlOutAction(inp));\r
- bucketsCurrentLength = bucketsCurrentLength + actionsLength;\r
+ actionsLength = input.readUnsignedShort();//empty header length\r
+ actionsList.add(ActionsDeserializer.createCopyTtlOutAction(input));\r
break;\r
\r
case 12: \r
- actionsLength = inp.readUnsignedShort();//empty header length\r
- actionsList.add(ActionCreator.createCopyTtlInAction(inp));\r
- bucketsCurrentLength = bucketsCurrentLength + actionsLength;\r
+ actionsLength = input.readUnsignedShort();//empty header length\r
+ actionsList.add(ActionsDeserializer.createCopyTtlInAction(input));\r
break;\r
\r
case 15: \r
- actionsLength = inp.readUnsignedShort();//empty header length\r
- actionsList.add(ActionCreator.createSetMplsTtlAction(inp));\r
- bucketsCurrentLength = bucketsCurrentLength + actionsLength;\r
+ actionsLength = input.readUnsignedShort();//empty header length\r
+ actionsList.add(ActionsDeserializer.createSetMplsTtlAction(input));\r
break;\r
\r
case 16: \r
- actionsLength = inp.readUnsignedShort();//empty header length\r
- actionsList.add(ActionCreator.createDecMplsTtlOutAction(inp));\r
- bucketsCurrentLength = bucketsCurrentLength + actionsLength;\r
+ actionsLength = input.readUnsignedShort();//empty header length\r
+ actionsList.add(ActionsDeserializer.createDecMplsTtlOutAction(input));\r
break;\r
\r
case 17: \r
- actionsLength = inp.readUnsignedShort();\r
- actionsList.add(ActionCreator.createPushVlanAction(inp));\r
- bucketsCurrentLength = bucketsCurrentLength + actionsLength;\r
+ actionsLength = input.readUnsignedShort();\r
+ actionsList.add(ActionsDeserializer.createPushVlanAction(input));\r
break;\r
\r
case 18: \r
- actionsLength = inp.readUnsignedShort();//empty header length\r
- actionsList.add(ActionCreator.createPopVlanAction(inp));\r
- bucketsCurrentLength = bucketsCurrentLength + actionsLength;\r
+ actionsLength = input.readUnsignedShort();//empty header length\r
+ actionsList.add(ActionsDeserializer.createPopVlanAction(input));\r
break;\r
\r
case 19: \r
- actionsLength = inp.readUnsignedShort();//8\r
- actionsList.add(ActionCreator.createPushMplsAction(inp));\r
- bucketsCurrentLength = bucketsCurrentLength + actionsLength;\r
+ actionsLength = input.readUnsignedShort();//8\r
+ actionsList.add(ActionsDeserializer.createPushMplsAction(input));\r
break;\r
\r
case 20: \r
- actionsLength = inp.readUnsignedShort();//8\r
- actionsList.add(ActionCreator.createPopMplsAction(inp));\r
- bucketsCurrentLength = bucketsCurrentLength + actionsLength;\r
+ actionsLength = input.readUnsignedShort();//8\r
+ actionsList.add(ActionsDeserializer.createPopMplsAction(input));\r
break;\r
\r
case 21: \r
- actionsLength = inp.readUnsignedShort();\r
- actionsList.add(ActionCreator.createSetQueueAction(inp));\r
- bucketsCurrentLength = bucketsCurrentLength + actionsLength;\r
+ actionsLength = input.readUnsignedShort();\r
+ actionsList.add(ActionsDeserializer.createSetQueueAction(input));\r
break;\r
\r
case 22: \r
- actionsLength = inp.readUnsignedShort();//8\r
- actionsList.add(ActionCreator.createGroupAction(inp));\r
- bucketsCurrentLength = bucketsCurrentLength + actionsLength;\r
+ actionsLength = input.readUnsignedShort();//8\r
+ actionsList.add(ActionsDeserializer.createGroupAction(input));\r
break;\r
\r
case 23: \r
- actionsLength = inp.readUnsignedShort();//8\r
- actionsList.add(ActionCreator.createSetNwTtlAction(inp));\r
- bucketsCurrentLength = bucketsCurrentLength + actionsLength;\r
+ actionsLength = input.readUnsignedShort();//8\r
+ actionsList.add(ActionsDeserializer.createSetNwTtlAction(input));\r
break;\r
\r
case 24: \r
- actionsLength = inp.readUnsignedShort();//empty header length\r
- actionsList.add(ActionCreator.createDecNwTtlAction(inp));\r
- bucketsCurrentLength = bucketsCurrentLength + actionsLength;\r
+ actionsLength = input.readUnsignedShort();//empty header length\r
+ actionsList.add(ActionsDeserializer.createDecNwTtlAction(input));\r
break;\r
\r
case 25:\r
- actionsLength = inp.readUnsignedShort();//8\r
+ actionsLength = input.readUnsignedShort();//8\r
//TODO field\r
- actionsList.add(ActionCreator.createSetFieldAction(inp, actionsLength));\r
- bucketsCurrentLength = bucketsCurrentLength + actionsLength;\r
+ actionsList.add(ActionsDeserializer.createSetFieldAction(input, actionsLength));\r
break; \r
case 26: \r
- actionsLength = inp.readUnsignedShort();//8\r
- actionsList.add(ActionCreator.createPushPbbAction(inp));\r
- bucketsCurrentLength = bucketsCurrentLength + actionsLength;\r
+ actionsLength = input.readUnsignedShort();//8\r
+ actionsList.add(ActionsDeserializer.createPushPbbAction(input));\r
break;\r
\r
case 27: \r
- actionsLength = inp.readUnsignedShort();//empty header length\r
- actionsList.add(ActionCreator.createPopPbbAction(inp));\r
- bucketsCurrentLength = bucketsCurrentLength + actionsLength;\r
+ actionsLength = input.readUnsignedShort();//empty header length\r
+ actionsList.add(ActionsDeserializer.createPopPbbAction(input));\r
break;\r
\r
case 0xFFFF: \r
- actionsLength = inp.readUnsignedShort();\r
- actionsList.add(ActionCreator.createExperimenterAction(inp));\r
- bucketsCurrentLength = bucketsCurrentLength + actionsLength;\r
+ actionsLength = input.readUnsignedShort();\r
+ actionsList.add(ActionsDeserializer.createExperimenterAction(input));\r
break;\r
default: \r
break;\r
}\r
+ bucketsCurrentLength += actionsLength;\r
} \r
return actionsList;\r
}\r
\r
actionBuilder.setType(Output.class);\r
PortActionBuilder port = new PortActionBuilder();\r
- port.setPort(new AnyPortNumber(new PortNumber(in.readUnsignedInt())));\r
+ port.setPort(new PortNumber(in.readUnsignedInt()));\r
actionBuilder.addAugmentation(PortAction.class, port.build());\r
MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder();\r
maxLen.setMaxLength(in.readUnsignedShort());\r
public static ActionsList createSetFieldAction(ByteBuf in, int actionLength) {\r
actionBuilder.setType(SetField.class);\r
OxmFieldsActionBuilder matchEntries = new OxmFieldsActionBuilder();\r
- matchEntries.setMatchEntries(MatchEntriesCreator.createMatchEntry(in, actionLength - 4));\r
+ matchEntries.setMatchEntries(MatchEntriesDeserializer.createMatchEntry(in, actionLength - 4));\r
actionBuilder.addAugmentation(OxmFieldsAction.class, matchEntries.build());\r
actionsListBuilder.setAction(actionBuilder.build());\r
\r