X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflow-protocol-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowjava%2Fprotocol%2Fimpl%2Futil%2FInstructionsDeserializer.java;fp=openflow-protocol-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowjava%2Fprotocol%2Fimpl%2Futil%2FInstructionsDeserializer.java;h=a8cb2803b25a5a37a8b92ffc927e28df8f8425e4;hb=74c40e7b03d3760a14ce2724d2b8c068f08b121c;hp=696e3ba2f4860331e75b228b905d475c6bd82da4;hpb=6f617b9dee9173581e8501dcd3c2f365f9a04f79;p=openflowjava.git diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializer.java index 696e3ba2..a8cb2803 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializer.java @@ -38,7 +38,7 @@ import io.netty.buffer.ByteBuf; * @author michal.polkorab * @author timotej.kubas */ -public class InstructionsDeserializer { +public abstract class InstructionsDeserializer { private static final byte WRITE_APPLY_CLEAR_ACTION_LENGTH = 8; private static final byte EXPERIMENTER_HEADER_LENGTH = 8; @@ -107,6 +107,52 @@ public class InstructionsDeserializer { return instructions; } + /** + * Creates instruction ids (instructions without values) + * @param input + * @param length + * @return list of ofp_instruction without values + */ + public static List createInstructionIds(ByteBuf input, int length) { + List instructions = new ArrayList<>(); + if (input.readableBytes() != 0) { + int lengthOfInstructions = length; + while (lengthOfInstructions > 0) { + InstructionsBuilder builder = new InstructionsBuilder(); + int type = input.readUnsignedShort(); + int instructionLength = input.readUnsignedShort(); + lengthOfInstructions -= instructionLength; + switch (type) { + case 1: + builder.setType(GotoTable.class); + break; + case 2: + builder.setType(WriteMetadata.class); + break; + case 3: + builder.setType(WriteActions.class); + break; + case 4: + builder.setType(ApplyActions.class); + break; + case 5: + builder.setType(ClearActions.class); + break; + case 6: + builder.setType(Meter.class); + break; + case 65535: + builder.setType(Experimenter.class); + break; + default: + break; + } + instructions.add(builder.build()); + } + } + return instructions; + } + private static void createGotoTableInstruction(InstructionsBuilder builder, ByteBuf input) { builder.setType(GotoTable.class);