public class MessageFactory extends AbstractFactory
| Modifier and Type | Class and Description |
|---|---|
static class |
MessageFactory.TestReset
Denotes things that can be reset, during unit tests.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
assignXid(MutableMessage msg)
Assigns the next available transaction ID to the specified message.
|
static void |
checkVersionSupported(ProtocolVersion pv)
Throws an exception if the specified version is not supported by
this OpenFlow message library.
|
static OpenflowMessage |
copy(OpenflowMessage msg)
Creates an immutable (deep) copy of the specified OpenFlow message.
|
static void |
copyXid(OpenflowMessage src,
MutableMessage dst)
Copies the transaction ID from given source message to the specified
destination message.
|
static MutableMessage |
create(Message msg,
MessageType type)
Creates a mutable OpenFlow message of the specified type, with
protocol version and transaction ID matching those of the given
message.
|
static MutableMessage |
create(Message msg,
MessageType type,
Enum<?> subtype)
Creates a mutable OpenFlow message of the specified type and subtype,
with protocol version and transaction ID matching those of the given
message.
|
static MutableMessage |
create(ProtocolVersion pv,
MessageType type)
Creates a mutable OpenFlow message of the specified type, with the
specified protocol version, assigning it the next available
transaction ID.
|
static MutableMessage |
create(ProtocolVersion pv,
MessageType type,
Enum<?> subtype)
Creates a mutable OpenFlow message of the specified type and subtype,
with the specified protocol version, assigning it the next available
transaction ID.
|
static OfmMutablePacketOut |
createPacketOutFromPacketIn(OfmPacketIn pi)
Creates a mutable packet-out message pre-populated with salient data
from the given packet-in message.
|
static byte[] |
encodeMessage(OpenflowMessage msg)
Encodes the specified OpenFlow message, returning the result in
a newly allocated byte array.
|
static void |
encodeMessage(OpenflowMessage msg,
ByteBuffer buffer)
Encodes the specified OpenFlow message into the supplied byte buffer.
|
static UnitTestSupport |
getTestSupport()
Returns a unit test support instance, to allow priviledged operations
to be performed by test code.
|
static boolean |
isStrictMessageParsing()
Returns true if strict message parsing is in effect.
|
static boolean |
isVersionSupported(ProtocolVersion pv)
Returns true if the specified version is supported by this
OpenFlow message library.
|
static MutableMessage |
mutableCopy(OpenflowMessage msg)
Creates a mutable (deep) copy of the specified OpenFlow message.
|
static OpenflowMessage |
parseMessage(ByteBuffer buffer)
Parses a single OpenFlow message from the supplied byte buffer
consuming the bytes in the process.
|
static OpenflowMessage |
parseMessage(OfPacketReader pkt)
Parses the supplied packet reader as a single OpenFlow message.
|
static OpenflowMessage |
parseMessage(OfPacketReader pkt,
OpenflowMessage msg)
Parses the supplied packet reader as a single OpenFlow message, but
patches in the XID of the specified message.
|
static void |
setStrictMessageParsing(boolean strict)
Sets message parsing to be either strict or non-strict.
|
static Set<ProtocolVersion> |
supportedVersions()
Returns the set of OpenFlow protocol versions that this library
supports.
|
protected String |
tag()
Returns an identifying tag for the message factory.
|
mpe, mpe, mpe, mpeprotected String tag()
tag in class AbstractFactorypublic static Set<ProtocolVersion> supportedVersions()
public static void checkVersionSupported(ProtocolVersion pv)
pv - the protocol version to checkVersionNotSupportedException - if the version is not supportedpublic static boolean isVersionSupported(ProtocolVersion pv)
pv - the protocol version to checkpublic static void setStrictMessageParsing(boolean strict)
In strict mode, the message parser will expect all non-spec-defined bits in bitmaps, and reserved fields, to be zero; if a 1-bit is found, an exception will be thrown.
In non-strict mode, the message parser will zero-out all non-spec-defined bits in bitmaps, and reserved fields, before parsing.
strict - true, for strict message parsing; false for non-strictpublic static boolean isStrictMessageParsing()
setStrictMessageParsing(boolean)public static OpenflowMessage parseMessage(ByteBuffer buffer) throws MessageParseException
buffer - byte buffer containing the message encodingNullPointerException - if buffer is nullMessageParseException - if a message cannot be parsed from the
reader contentspublic static OpenflowMessage parseMessage(OfPacketReader pkt) throws MessageParseException
pkt - the packet readerNullPointerException - if pkt is nullMessageParseException - if a message cannot be parsed from
the reader contentspublic static OpenflowMessage parseMessage(OfPacketReader pkt, OpenflowMessage msg) throws MessageParseException
pkt - the packet readermsg - the (request) message from which to take the XIDNullPointerException - if either parameter is nullMessageParseException - if a message cannot be parsed from
the reader contentspublic static MutableMessage create(ProtocolVersion pv, MessageType type, Enum<?> subtype)
pv - the protocol version to settype - the required message typesubtype - the required message subtypeNullPointerException - if any parameter is nullVersionNotSupportedException - if the required message cannot be
created for the given versionpublic static MutableMessage create(ProtocolVersion pv, MessageType type)
pv - the protocol version to settype - the required message typeNullPointerException - if either parameter is nullVersionNotSupportedException - if the required message cannot be
created for the given versionpublic static MutableMessage create(Message msg, MessageType type)
msg - the message from which to copy the protocol version
and transaction idtype - the required message typeNullPointerException - if either parameter is nullVersionNotSupportedException - if the required message cannot be
created for the given versionpublic static MutableMessage create(Message msg, MessageType type, Enum<?> subtype)
msg - the message from which to copy the protocol version
and transaction idtype - the required message typesubtype - the required message subtypeNullPointerException - if either parameter is nullVersionNotSupportedException - if the required message cannot be
created for the given versionpublic static OfmMutablePacketOut createPacketOutFromPacketIn(OfmPacketIn pi)
pi - the source packet-inIllegalArgumentException - if the packet-in is mutablepublic static void assignXid(MutableMessage msg)
copyXid(com.h3c.of.lib.msg.OpenflowMessage, com.h3c.of.lib.msg.MutableMessage) method, or implicitly through the
create(com.h3c.of.lib.ProtocolVersion, com.h3c.of.lib.msg.MessageType, java.lang.Enum<?>) methods (which call this method).msg - the mutable message to which the next transaction ID
is to be assignedNullPointerException - if msg is nullInvalidMutableException - if the message is not writablepublic static void copyXid(OpenflowMessage src, MutableMessage dst)
src - the message whose XID should be copieddst - the (mutable) message into which the XID should be copiedNullPointerException - if either parameter is nullInvalidMutableException - if dst is not writablepublic static OpenflowMessage copy(OpenflowMessage msg)
msg - the message to copypublic static MutableMessage mutableCopy(OpenflowMessage msg)
msg - the message to copypublic static void encodeMessage(OpenflowMessage msg, ByteBuffer buffer) throws IncompleteMessageException, IncompleteStructureException
msg - the message to encodebuffer - byte buffer to receive message bytesIllegalArgumentException - if the message is mutableIncompleteMessageException - if the message was
insufficiently initializedIncompleteStructureException - if any internal structure
was insufficiently initializedpublic static byte[] encodeMessage(OpenflowMessage msg) throws IncompleteMessageException, IncompleteStructureException
msg - the message to encodeIllegalArgumentException - if the message is mutableIncompleteMessageException - if the message was
insufficiently initializedIncompleteStructureException - if any internal structure
was insufficiently initializedpublic static UnitTestSupport getTestSupport()
Copyright © 2014. All Rights Reserved.