public class InstructionFactory extends AbstractFactory
Instruction
instances.Modifier and Type | Method and Description |
---|---|
static Instruction |
createInstruction(ProtocolVersion pv,
InstructionType type)
Creates a CLEAR_ACTIONS instruction.
|
static Instruction |
createInstruction(ProtocolVersion pv,
InstructionType type,
ExperimenterId eid,
byte[] data)
Creates an EXPERIMENTER instruction.
|
static Instruction |
createInstruction(ProtocolVersion pv,
InstructionType type,
int id,
byte[] data)
Creates an EXPERIMENTER instruction.
|
static Instruction |
createInstruction(ProtocolVersion pv,
InstructionType type,
long metadata,
long mask)
Creates a WRITE_METADATA instruction.
|
static Instruction |
createInstruction(ProtocolVersion pv,
InstructionType type,
MeterId mid)
Creates a METER instruction.
|
static Instruction |
createInstruction(ProtocolVersion pv,
InstructionType type,
TableId tid)
Creates a GOTO_TABLE instruction.
|
static List<Instruction> |
createInstructionHeaders(ProtocolVersion pv,
Set<InstructionType> types)
Creates instruction headers to be used in encoding a table features
instructions property.
|
static InstrMutableAction |
createMutableInstruction(ProtocolVersion pv,
InstructionType type)
Creates a mutable (action-based) instruction.
|
static void |
encodeInstrExperList(List<InstrExperimenter> instrs,
OfPacketWriter pkt)
Encodes a list of experimenter instructions, writing them into the
supplied buffer.
|
static void |
encodeInstruction(Instruction ins,
OfPacketWriter pkt)
Encodes an instruction, writing it into the supplied buffer.
|
static void |
encodeInstructionList(List<Instruction> instrs,
OfPacketWriter pkt)
Encodes a list of instructions, writing them into the supplied
buffer.
|
static Instruction |
parseInstruction(OfPacketReader pkt,
ProtocolVersion pv)
Parses an Instruction structure from the supplied buffer.
|
static List<Instruction> |
parseInstructionHeaders(int targetRi,
OfPacketReader pkt,
ProtocolVersion pv)
Parses a list of instruction header structures from the supplied
buffer.
|
static List<Instruction> |
parseInstructionList(int targetRi,
OfPacketReader pkt,
ProtocolVersion pv)
Parses a list of instruction structures from the supplied buffer.
|
protected String |
tag()
Returns an identifying tag for the instruction factory.
|
static String |
toDebugString(int indent,
List<Instruction> ins)
Outputs a list of instructions in debug string format.
|
static void |
validateInstruction(ProtocolVersion pv,
Instruction ins,
String msgType)
Ensures that the specified instruction is appropriate to add to
a message of the specified version.
|
mpe, mpe, mpe, mpe
protected String tag()
tag
in class AbstractFactory
public static List<Instruction> parseInstructionList(int targetRi, OfPacketReader pkt, ProtocolVersion pv) throws MessageParseException
Note that this method causes the reader index of the underlying
PacketBuffer
to be advanced by the length of the list,
which should leave the reader index at targetRi
.
targetRi
- the target reader indexpkt
- the data bufferpv
- the protocol versionMessageParseException
- if unable to parse the structurepublic static Instruction parseInstruction(OfPacketReader pkt, ProtocolVersion pv) throws MessageParseException
PacketBuffer
to be advanced by the length of the structure.
Also note that this method resets and uses the buffer's
odometer, to verify that the total number of bytes parsed
is divisible by 8.pkt
- the data bufferpv
- the protocol versionMessageParseException
- if unable to parse the structurepublic static List<Instruction> parseInstructionHeaders(int targetRi, OfPacketReader pkt, ProtocolVersion pv) throws MessageParseException
InstrHeader
instances or InstrExperimenter
instances.targetRi
- the target reader indexpkt
- the data bufferpv
- the protocol versionMessageParseException
- if unable to parse the structureTableFeatureFactory
,
TableFeaturePropInstr
public static Instruction createInstruction(ProtocolVersion pv, InstructionType type, TableId tid)
pv
- the protocol versiontype
- the instruction type (GOTO_TABLE)tid
- the table idVersionNotSupportedException
- if the version is not supportedNullPointerException
- if any required parameter is nullIllegalArgumentException
- if type is not GOTO_TABLEpublic static Instruction createInstruction(ProtocolVersion pv, InstructionType type, long metadata, long mask)
pv
- the protocol versiontype
- the instruction type (WRITE_METADATA)metadata
- the metadatamask
- the metadata maskVersionNotSupportedException
- if the version is not supportedNullPointerException
- if any required parameter is nullIllegalArgumentException
- if type is not WRITE_METADATApublic static InstrMutableAction createMutableInstruction(ProtocolVersion pv, InstructionType type)
pv
- the protocol versiontype
- the instruction type (WRITE_ACTIONS, APPLY_ACTIONS)VersionNotSupportedException
- if the version is not supportedNullPointerException
- if any required parameter is nullIllegalArgumentException
- if type is not WRITE_ACTIONS or
APPLY_ACTIONSpublic static Instruction createInstruction(ProtocolVersion pv, InstructionType type)
Note, use createMutableInstruction(com.hp.of.lib.ProtocolVersion, com.hp.of.lib.instr.InstructionType)
for WRITE_ACTIONS
or APPLY_ACTIONS
.
pv
- the protocol versiontype
- the instruction type (CLEAR_ACTIONS)VersionNotSupportedException
- if the version is not supportedNullPointerException
- if any required parameter is nullIllegalArgumentException
- if type is not CLEAR_ACTIONSpublic static Instruction createInstruction(ProtocolVersion pv, InstructionType type, MeterId mid)
pv
- the protocol versiontype
- the instruction type (METER)mid
- the meter idVersionNotSupportedException
- if the version is not supportedNullPointerException
- if any required parameter is nullIllegalArgumentException
- if type is not METERpublic static Instruction createInstruction(ProtocolVersion pv, InstructionType type, int id, byte[] data)
pv
- the protocol versiontype
- the instruction type (EXPERIMENTER)id
- the experimenter encoded IDdata
- experimenter-defined dataVersionNotSupportedException
- if the version is not supportedNullPointerException
- if any required parameter is nullIllegalArgumentException
- if type is not EXPERIMENTER or if
data array is an unsupported lengthpublic static Instruction createInstruction(ProtocolVersion pv, InstructionType type, ExperimenterId eid, byte[] data)
pv
- the protocol versiontype
- the instruction type (EXPERIMENTER)eid
- the experimenter IDdata
- experimenter-defined dataVersionNotSupportedException
- if the version is not supportedNullPointerException
- if any required parameter is nullIllegalArgumentException
- if type is not EXPERIMENTER or if
data array is an unsupported lengthpublic static List<Instruction> createInstructionHeaders(ProtocolVersion pv, Set<InstructionType> types)
pv
- the protocol versiontypes
- the types of headers to createVersionNotSupportedException
- if the version is not supportedNullPointerException
- if any required parameter is nullpublic static void encodeInstruction(Instruction ins, OfPacketWriter pkt)
PacketBuffer
to be advanced by the length of the instruction.ins
- the instructionpkt
- the buffer into which the instruction is to be writtenpublic static void encodeInstructionList(List<Instruction> instrs, OfPacketWriter pkt)
PacketBuffer
to be advanced by the length of
the written instructions.instrs
- the list of instructionspkt
- the buffer into which the instructions are to be writtenpublic static void encodeInstrExperList(List<InstrExperimenter> instrs, OfPacketWriter pkt)
PacketBuffer
to be advanced by the length of
the written instructions.instrs
- the list of instructionspkt
- the buffer into which the instructions are to be writtenpublic static String toDebugString(int indent, List<Instruction> ins)
indent
- the additional indent (number of spaces)ins
- the list of instructionspublic static void validateInstruction(ProtocolVersion pv, Instruction ins, String msgType)
pv
- the protocol versionins
- the instruction to validatemsgType
- the message type (label)IllegalArgumentException
- if the instruction is invalidCopyright © 2015. All Rights Reserved.