public class TestMessageContext extends Object implements MessageContext
SequencedPacketListener
(SPL).
Note that this implementation allows access to the
PacketOut
API whereas in the production code this will
be restricted to only those SPLs that register as a Director.
Also note that a constructor is provided that takes an OfmPacketIn
argument. Internally, this is wrapped in a mock message event. This will
hopefully reduce the amount of unnecessary boiler-plate code required to set
up the mock context.
Modifier and Type | Field and Description |
---|---|
static DataPathId |
DPID
A test datapath ID, used by default.
|
Constructor and Description |
---|
TestMessageContext(MessageEvent srcEvent)
Constructs the message context for the given PacketIn
message event.
|
TestMessageContext(OfmPacketIn packetIn)
Constructs the message context for the given PacketIn
message, by wrapping the message in a mock event, using the default
datapath ID . |
TestMessageContext(OfmPacketIn packetIn,
DataPathId dpid)
Constructs the message context for the given PacketIn
message, by wrapping the message in a mock event, using the supplied
datapath ID.
|
Modifier and Type | Method and Description |
---|---|
MessageContext |
addHint(Hint hint)
Adds a hint to the context.
|
Packet |
decodedPacket()
Returns the decoded packet data generated by the Network Packet Library
facility.
|
boolean |
failedToSend()
This flag is set in the unlikely event that the packet sequencer
failed to send the PacketOut message via the controller.
|
OfmPacketOut |
getCompletedPacketOut()
Returns the PacketOut message that was sent back to the
source datapath.
|
List<Hint> |
getHints()
Returns the hints contained in this context, in the order they were
added by the Advisors.
|
OfmPacketIn |
getPacketIn()
Convenience method that returns the PacketIn message from
the message event.
|
List<ProtocolId> |
getProtocols()
Returns an ordered list of
protocols decoded
from the packet. |
ProtocolVersion |
getVersion()
Returns the protocol version of the associated PacketIn
message event.
|
boolean |
isBlocked()
Returns true if response (packet-out message) to the associated
message event has been blocked.
|
boolean |
isHandled()
Returns true if the associated message event has already been handled.
|
boolean |
isSent()
Returns true if response (packet-out message) to the associated
message event has been sent.
|
boolean |
isTestPacket()
Returns true if the associated packet has been determined to be a
diagnostic test packet.
|
PacketOut |
packetOut()
Returns the API for manipulating the PacketOut message.
|
boolean |
requiresProcessing()
Returns true if the associated packet is not a test packet, and has
not yet been blocked or sent and thus continues to require processing.
|
TestMessageContext |
setDecodedPacket(Packet packet)
Replaces the "decoded" packet with the given instance.
|
MessageEvent |
srcEvent()
Returns the associated PacketIn message event.
|
String |
toDebugString()
Returns a multi-line string representation of this message context,
suitable for debugging.
|
String |
toString() |
public static final DataPathId DPID
public TestMessageContext(OfmPacketIn packetIn)
datapath ID
.packetIn
- the source messagepublic TestMessageContext(OfmPacketIn packetIn, DataPathId dpid)
packetIn
- the source messagedpid
- the source datapath IDpublic TestMessageContext(MessageEvent srcEvent)
srcEvent
- the source message eventpublic TestMessageContext setDecodedPacket(Packet packet)
packet
- the packet to setpublic String toDebugString()
MessageContext
toDebugString
in interface MessageContext
public MessageEvent srcEvent()
MessageContext
srcEvent
in interface MessageContext
public ProtocolVersion getVersion()
MessageContext
getVersion
in interface MessageContext
public OfmPacketIn getPacketIn()
MessageContext
getPacketIn
in interface MessageContext
public Packet decodedPacket()
MessageContext
decodedPacket
in interface MessageContext
public List<ProtocolId> getProtocols()
MessageContext
protocols
decoded
from the packet. The protocols are ordered from outermost to innermost
layer. This will be null if there is no packet data associated
with the PacketIn message.getProtocols
in interface MessageContext
public boolean isHandled()
MessageContext
isHandled
in interface MessageContext
public boolean isBlocked()
MessageContext
isBlocked
in interface MessageContext
public boolean isSent()
MessageContext
isSent
in interface MessageContext
public boolean isTestPacket()
MessageContext
isTestPacket
in interface MessageContext
public boolean requiresProcessing()
MessageContext
requiresProcessing
in interface MessageContext
public boolean failedToSend()
MessageContext
failedToSend
in interface MessageContext
public PacketOut packetOut()
MessageContext
packetOut
in interface MessageContext
public OfmPacketOut getCompletedPacketOut()
MessageContext
getCompletedPacketOut
in interface MessageContext
public MessageContext addHint(Hint hint)
MessageContext
addHint
in interface MessageContext
hint
- the hint to be addedpublic List<Hint> getHints()
MessageContext
getHints
in interface MessageContext
Copyright © 2015. All Rights Reserved.