public class ActionFactory extends AbstractFactory
Action
instances.
Used by the InstructionFactory
in its loftier goal of creating
action-list-based instructions.
Modifier and Type | Method and Description |
---|---|
static Action |
createAction(ProtocolVersion pv,
ActionType type)
Creates an action (header only, no payload),
using the specified protocol version.
|
static Action |
createAction(ProtocolVersion pv,
ActionType type,
BigPortNumber port)
Creates an OUTPUT action.
|
static Action |
createAction(ProtocolVersion pv,
ActionType type,
BigPortNumber port,
int maxLen)
Creates an OUTPUT action.
|
static Action |
createAction(ProtocolVersion pv,
ActionType type,
EthernetType ethType)
Creates an EthernetType-based action.
|
static Action |
createAction(ProtocolVersion pv,
ActionType type,
ExperimenterId eid,
byte[] data)
Creates an EXPERIMENTER action.
|
static Action |
createAction(ProtocolVersion pv,
ActionType type,
GroupId id)
Creates a GROUP action.
|
static Action |
createAction(ProtocolVersion pv,
ActionType type,
int ttl)
Creates a TTL-based action.
|
static Action |
createAction(ProtocolVersion pv,
ActionType type,
int id,
byte[] data)
Creates an EXPERIMENTER action.
|
static Action |
createAction(ProtocolVersion pv,
ActionType type,
MFieldBasic mf)
Creates a SET_FIELD action.
|
static Action |
createAction(ProtocolVersion pv,
ActionType type,
QueueId id)
Creates a SET_QUEUE action for version 1.1 onwards.
|
static Action |
createAction(ProtocolVersion pv,
ActionType type,
QueueId id,
BigPortNumber port)
Creates a SET_QUEUE action (used to be named ENQUEUE) for version 1.0.
|
static List<Action> |
createActionHeaders(ProtocolVersion pv,
Set<ActionType> types)
Creates action headers to be used in encoding a table features
actions property.
|
static Action |
createActionSetField(ProtocolVersion pv,
OxmBasicFieldType ft,
EthernetType ethType)
Creates a set-field action for an ETH_TYPE match field,
using the given protocol version.
|
static Action |
createActionSetField(ProtocolVersion pv,
OxmBasicFieldType ft,
ICMPv4Type icmpv4Type)
Creates a set-field action for an ICMPv4 Type match field,
using the given protocol version.
|
static Action |
createActionSetField(ProtocolVersion pv,
OxmBasicFieldType ft,
ICMPv6Type icmpv6Type)
Creates a set-field action for an ICMPv6 Type match field,
using the given protocol version.
|
static Action |
createActionSetField(ProtocolVersion pv,
OxmBasicFieldType ft,
int value)
Creates a set-field action for an int-payload-based match field,
using the given protocol version.
|
static Action |
createActionSetField(ProtocolVersion pv,
OxmBasicFieldType ft,
IpAddress ip)
Creates a set-field action for an ip-address-based match field,
using the given protocol version.
|
static Action |
createActionSetField(ProtocolVersion pv,
OxmBasicFieldType ft,
IpProtocol ipp)
Creates a set-field action for an IP Protocol match field,
using the given protocol version.
|
static Action |
createActionSetField(ProtocolVersion pv,
OxmBasicFieldType ft,
long value)
Creates a set-field action for a long-payload-based match field,
using the given protocol version.
|
static Action |
createActionSetField(ProtocolVersion pv,
OxmBasicFieldType ft,
MacAddress mac)
Creates a set-field action for a mac-address-based match field,
using the given protocol version.
|
static Action |
createActionSetField(ProtocolVersion pv,
OxmBasicFieldType ft,
Map<IPv6ExtHdr,Boolean> flags)
Creates a set-field action for an IPv6 Extension Header match field,
using the given protocol version.
|
static Action |
createActionSetField(ProtocolVersion pv,
OxmBasicFieldType ft,
PortNumber port)
Creates a set-field action for a port-number-based match field,
using the given protocol version.
|
static Action |
createActionSetField(ProtocolVersion pv,
OxmBasicFieldType ft,
VlanId vlanId)
Creates a set-field action for a VLAN_VID,
using the given protocol version.
|
static void |
encodeAction(Action act,
OfPacketWriter pkt)
Encodes an action, writing it into the supplied buffer.
|
static void |
encodeActionExperList(List<ActExperimenter> acts,
OfPacketWriter pkt)
Encodes a list of experimenter actions, writing them into the supplied
buffer.
|
static void |
encodeActionList(List<Action> acts,
OfPacketWriter pkt)
Encodes a list of actions, writing them into the supplied buffer.
|
static Action |
parseAction(OfPacketReader pkt,
ProtocolVersion pv)
Parses a single action from the supplied buffer.
|
static List<Action> |
parseActionHeaders(int targetRi,
OfPacketReader pkt,
ProtocolVersion pv)
Parses a list of action header structures from the supplied buffer.
|
static List<Action> |
parseActionList(int targetRi,
OfPacketReader pkt,
ProtocolVersion pv)
Parses a list of action structures from the supplied buffer.
|
protected String |
tag()
Returns an identifying tag for the action factory.
|
static String |
toDebugString(int indent,
List<Action> acts)
Outputs a list of actions in debug string format.
|
static void |
validateAction(ProtocolVersion pv,
Action act,
String msgType)
Ensures that the specified action is appropriate to add to a message of
the specified version.
|
mpe, mpe, mpe, mpe
protected String tag()
tag
in class AbstractFactory
public static Action parseAction(OfPacketReader pkt, ProtocolVersion pv) throws MessageParseException
PacketBuffer
to be advanced by the length of the action.pkt
- the data bufferpv
- the protocol versionMessageParseException
- if unable to parse the actionpublic static List<Action> parseActionList(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 List<Action> parseActionHeaders(int targetRi, OfPacketReader pkt, ProtocolVersion pv) throws MessageParseException
ActHeader
instances or ActExperimenter
instances.targetRi
- the target reader indexpkt
- the data bufferpv
- the protocol versionMessageParseException
- if there is an issue parsing the structureTableFeatureFactory
,
TableFeaturePropAction
public static Action createAction(ProtocolVersion pv, ActionType type)
pv
- the protocol versiontype
- the type of actionVersionNotSupportedException
- if the version is not supportedNullPointerException
- if any required parameter is nullIllegalArgumentException
- if type is inappropriatepublic static Action createAction(ProtocolVersion pv, ActionType type, MFieldBasic mf)
The supplied match field should be a basic match field with its type identifying the field to set, and its value denoting the value to set. There must be no mask included.
Additional note: The match of the flow entry must contain the OXM prerequisite corresponding to the field to be set, otherwise an error will be generated.
The type of the set-field action can be any valid
OXM header type
.
Set-field actions for types
IN_PORT
,
IN_PHY_PORT
, and
METADATA
are not supported,
because those are not header fields.
The set-field actions overwrite the header field specified by the OXM type, and perform the necessary CRC recalculation based on the header field. The OXM fields refer to the outermost-possible occurrence in the header, unless the field type explicitly specifies otherwise, and therefore in general the set-field actions apply to the outermost-possible header (e.g. a "Set VLAN ID" set-field action always sets the ID of the outermost VLAN tag).
pv
- the protocol versiontype
- the action type (SET_FIELD)mf
- the match fieldVersionNotSupportedException
- if the version is not supportedNullPointerException
- if any required parameter is nullIllegalArgumentException
- if type is not SET_FIELD, or if
mf is inappropriateFieldFactory
public static Action createAction(ProtocolVersion pv, ActionType type, BigPortNumber port, int maxLen)
When port is Port.CONTROLLER
(i.e. the action is to output
the packet to the controller), maxLen
indicates the
maximum number of bytes of the frame (from 0 to CONTROLLER_MAX)
to send to the controller:
ActOutput.CONTROLLER_MAX
: at most, send
this number of bytes
ActOutput.CONTROLLER_NO_BUFFER
: the complete packet
is to be sent
When port is not Port.CONTROLLER
, the
maxLen
value should be ignored (since the only reasonable action
is to send all the bytes of the packet), but this method will
allow a value of either 0 or
ActOutput.CONTROLLER_NO_BUFFER
to be set.
The degenerate form
of this method invokes this method with maxLen
equal to 0.
Note that in 1.0, port numbers are u16.
pv
- the protocol versiontype
- the action type (OUTPUT)port
- output portmaxLen
- max length to send to the controllerVersionNotSupportedException
- if the version is not supportedNullPointerException
- if any required parameter is nullIllegalArgumentException
- if type is not OUTPUT, or if
maxLen is out of bounds, or if the port number is invalidpublic static Action createAction(ProtocolVersion pv, ActionType type, BigPortNumber port)
If the required output port is Port.CONTROLLER
, use
createAction(ProtocolVersion, ActionType, BigPortNumber, int)
instead.
pv
- the protocol versiontype
- the action type (OUTPUT)port
- output portVersionNotSupportedException
- if the version is not supportedNullPointerException
- if any required parameter is nullIllegalArgumentException
- if type is not OUTPUT, or if
port is CONTROLLERpublic static Action createAction(ProtocolVersion pv, ActionType type, GroupId id)
pv
- the protocol versiontype
- the action type (GROUP)id
- the group idVersionNotSupportedException
- if the version is not supportedVersionMismatchException
- if the version is < 1.1NullPointerException
- if any required parameter is nullIllegalArgumentException
- if type is not GROUPpublic static Action createAction(ProtocolVersion pv, ActionType type, QueueId id)
pv
- the protocol versiontype
- the action type (SET_QUEUE)id
- the queue idVersionNotSupportedException
- if the version is not supportedNullPointerException
- if any required parameter is nullIllegalArgumentException
- if type is not SET_QUEUEpublic static Action createAction(ProtocolVersion pv, ActionType type, QueueId id, BigPortNumber port)
The specified port is the port to which the queue belongs. It should
refer to a valid physical port; that is less than MAX
(defined as 0xff00
in 1.0) or equal to Port.IN_PORT
.
Note that in 1.0, port numbers are u16.
pv
- the protocol versiontype
- the action type (SET_QUEUE)id
- the queue idport
- the port to which the queue belongsVersionNotSupportedException
- if the version is not supportedNullPointerException
- if any required parameter is nullIllegalArgumentException
- if type is not SET_QUEUE, or if the
port number is invalidpublic static Action createAction(ProtocolVersion pv, ActionType type, int ttl)
pv
- the protocol versiontype
- the action type (SET_MPLS_TTL or SET_NW_TTL)ttl
- the TTL value (u8)VersionNotSupportedException
- if the version is not supportedVersionMismatchException
- if the version is < 1.1NullPointerException
- if any required parameter is nullIllegalArgumentException
- if type is inappropriate or
ttl is out of boundspublic static Action createAction(ProtocolVersion pv, ActionType type, EthernetType ethType)
pv
- the protocol versiontype
- the action typeethType
- the EthernetType of the tag to be pushed/poppedVersionNotSupportedException
- if the version is not supportedNullPointerException
- if any required parameter is nullIllegalArgumentException
- if the ethernet type is not appropriatepublic static Action createAction(ProtocolVersion pv, ActionType type, int id, byte[] data)
pv
- the protocol versiontype
- the action type (EXPERIMENTER)id
- the experimenter encoded IDdata
- experimenter-defined dataVersionNotSupportedException
- if the version is not supportedNullPointerException
- if any required parameter is nullIllegalArgumentException
- if data is of an unsupported lengthpublic static Action createAction(ProtocolVersion pv, ActionType type, ExperimenterId eid, byte[] data)
pv
- the protocol versiontype
- the action type (EXPERIMENTER)eid
- the experimenter IDdata
- experimenter-defined dataVersionNotSupportedException
- if the version is not supportedNullPointerException
- if any required parameter is nullIllegalArgumentException
- if data is of an unsupported lengthpublic static Action createActionSetField(ProtocolVersion pv, OxmBasicFieldType ft, MacAddress mac)
pv
- the protocol versionft
- the field typemac
- the MAC addressVersionNotSupportedException
- if the version is not supportedNullPointerException
- if any required parameter is nullIllegalArgumentException
- if field type is not appropriatepublic static Action createActionSetField(ProtocolVersion pv, OxmBasicFieldType ft, IpAddress ip)
pv
- the protocol versionft
- the field typeip
- the IP addressVersionNotSupportedException
- if the version is not supportedNullPointerException
- if any required parameter is nullIllegalArgumentException
- if field type is not appropriate
or IP address family is not appropriatepublic static Action createActionSetField(ProtocolVersion pv, OxmBasicFieldType ft, PortNumber port)
pv
- the protocol versionft
- the field typeport
- the port numberVersionNotSupportedException
- if the version is not supportedNullPointerException
- if any required parameter is nullIllegalArgumentException
- if field type is not appropriatepublic static Action createActionSetField(ProtocolVersion pv, OxmBasicFieldType ft, ICMPv4Type icmpv4Type)
pv
- the protocol versionft
- the field type (ICMPV4_TYPE)icmpv4Type
- the ICMPv4 TypeVersionNotSupportedException
- if the version is not supportedNullPointerException
- if any required parameter is nullIllegalArgumentException
- if field type is not appropriatepublic static Action createActionSetField(ProtocolVersion pv, OxmBasicFieldType ft, ICMPv6Type icmpv6Type)
pv
- the protocol versionft
- the field type (ICMPV6_TYPE)icmpv6Type
- the ICMPv6 TypeVersionNotSupportedException
- if the version is not supportedNullPointerException
- if any required parameter is nullIllegalArgumentException
- if field type is not appropriatepublic static Action createActionSetField(ProtocolVersion pv, OxmBasicFieldType ft, int value)
pv
- the protocol versionft
- the field typevalue
- the valueVersionNotSupportedException
- if the version is not supportedNullPointerException
- if any required parameter is nullIllegalArgumentException
- if field type is not appropriate or
the value is not appropriatepublic static Action createActionSetField(ProtocolVersion pv, OxmBasicFieldType ft, EthernetType ethType)
pv
- the protocol versionft
- the field typeethType
- the Ethernet TypeVersionNotSupportedException
- if the version is not supportedNullPointerException
- if any required parameter is nullIllegalArgumentException
- if field type is not appropriatepublic static Action createActionSetField(ProtocolVersion pv, OxmBasicFieldType ft, VlanId vlanId)
pv
- the protocol versionft
- the field type (VLAN_VID)vlanId
- the VLAN vid to matchVersionNotSupportedException
- if the version is not supportedNullPointerException
- if any required parameter is nullIllegalArgumentException
- if field type is not appropriatepublic static Action createActionSetField(ProtocolVersion pv, OxmBasicFieldType ft, IpProtocol ipp)
pv
- the protocol versionft
- the field type (IP_PROTO)ipp
- the IP protocolVersionNotSupportedException
- if the version is not supportedNullPointerException
- if any required parameter is nullIllegalArgumentException
- if field type is not appropriatepublic static Action createActionSetField(ProtocolVersion pv, OxmBasicFieldType ft, long value)
pv
- the protocol versionft
- the field typevalue
- the valueVersionNotSupportedException
- if the version is not supportedNullPointerException
- if any required parameter is nullIllegalArgumentException
- if field type is not appropriate
or the value is not appropriatepublic static Action createActionSetField(ProtocolVersion pv, OxmBasicFieldType ft, Map<IPv6ExtHdr,Boolean> flags)
pv
- the protocol versionft
- the field type (IPV6_EXTHDR)flags
- the IPv6 Extension Header flagsVersionNotSupportedException
- if the version is not supportedNullPointerException
- if any required parameter is nullIllegalArgumentException
- if field type is not appropriatepublic static List<Action> createActionHeaders(ProtocolVersion pv, Set<ActionType> 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 encodeAction(Action act, OfPacketWriter pkt)
PacketBuffer
to be advanced by the length of the action.act
- the actionpkt
- the buffer into which the action is to be writtenpublic static void encodeActionList(List<Action> acts, OfPacketWriter pkt)
PacketBuffer
to be advanced by the length of the written
actions.acts
- the list of actionspkt
- the buffer into which the actions are to be writtenpublic static void encodeActionExperList(List<ActExperimenter> acts, OfPacketWriter pkt)
PacketBuffer
to be advanced by the length of the written
actions.acts
- the list of actionspkt
- the buffer into which the actions are to be writtenpublic static String toDebugString(int indent, List<Action> acts)
indent
- the additional indent (number of spaces)acts
- the list of actionspublic static void validateAction(ProtocolVersion pv, Action act, String msgType)
pv
- the protocol versionact
- the action to validatemsgType
- the message type (label)IllegalArgumentException
- if the action is invalidCopyright © 2015. All Rights Reserved.