public class PacketContext extends Object implements Cloneable, CachedPacketContext, PathMapContext, FlowFilterContext
PacketContext
class describes the context of received packet.
This class is designed to be used by a single thread.
Constructor and Description |
---|
PacketContext(PacketInEvent ev)
Construct a new packet context to handle PACKET_IN message.
|
PacketContext(TxContext ctx,
Ethernet ether,
SalPort ingress)
Construct a new packet context.
|
Modifier and Type | Method and Description |
---|---|
void |
addFilterAction(FlowFilterAction act)
Append the given flow action to the action list to be applied to packet.
|
void |
addFlow(VTNFlowBuilder builder)
Install the given data flow.
|
void |
addMatchField(FlowMatchType type)
Add a match field to be configured into a flow entry.
|
void |
addUnicastMatchFields()
Add match fields to be configured into an unicast flow entry.
|
void |
addVNodeHop(VNodeHop vhop)
Append the specified virtual node hop to the virtual packet route.
|
void |
broadcasted(RedirectFlowException rex,
VNodeIdentifier<?> ident)
Invoked when the redirected unicast packet was broadcasted to the
bridge.
|
PacketContext |
clone()
Return a copy of this instance.
|
void |
commit()
Commit all modifications to the packet.
|
VTNFlowBuilder |
createFlowBuilder(String tname,
VTNMatch vmatch)
Create a new VTN flow builder with specifying the flow match.
|
Ethernet |
createFrame(int vlan)
Create a new ethernet frame that forwards the received packet.
|
void |
destinationDisabled(RedirectFlowException rex)
Invoked when the destination virtual interface of the packet redirection
was disabled.
|
void |
destinationNotFound(RedirectFlowException rex,
String msg)
Invoked when the destination virtual interface of the packet redirection
was not found.
|
PacketContext |
evaluate(FlowFilterList fflist,
int vid)
Evaluate the given flow filter list against the packet.
|
void |
forwarded(RedirectFlowException rex,
VNodeIdentifier<?> to,
SalPort sport,
int vid)
Invoked when the final destination of the unicast packet redirection is
determined.
|
int |
getBaseFlowPriority()
Return the base flow priority.
|
EtherAddress |
getControllerAddress()
Return the MAC address of the controller.
|
String |
getDescription()
Return a brief description of the ethernet frame in this context.
|
String |
getDescription(EtherAddress src,
EtherAddress dst,
int type,
SalPort sport,
int vid)
Create a brief description of the ethernet frame.
|
String |
getDescription(Ethernet ether,
SalPort sport,
int vid)
Create a brief description of the ethernet frame.
|
String |
getDescription(SalPort sport)
Create a brief description of the ethernet frame in this context.
|
EtherAddress |
getDestinationAddress()
Return the destination MAC address.
|
VNodeHop |
getEgressVNodeHop()
Return a
VNodeHop instance which represents the virtual node
hop to the egress node. |
EtherHeader |
getEtherHeader()
Return an
EtherHeader instance which describes an Ethernet
header and IEEE 802.1Q VLAN tag. |
EtherPacket |
getEtherPacket()
Return an
EtherPacket instance which represents the Ethernet
frame. |
Collection<FlowFilterAction> |
getFilterActions()
Return a collection of flow actions configured by a flow filter.
|
RedirectFlowException |
getFirstRedirection()
Return a
RedirectFlowException which represents the first packet
redirection in a flow. |
VTNFlowCondition |
getFlowCondition(VTNFlowFilter ff)
Return a
VTNFlowCondition instance which determines whether the
specified flow filter needs to be applied to the packet. |
FlowCondReader |
getFlowCondReader()
Return the flow condition reader associated with the current MD-SAL
datastore transaction.
|
int |
getFlowPriority()
Return a priority value for flow entries.
|
Ethernet |
getFrame()
Return an ethernet frame in this context.
|
int |
getHardTimeout()
Return the hard timeout for a flow entry.
|
String |
getHeaderDescription()
Return a description about protocol headers.
|
int |
getIdleTimeout()
Return the idle timeout for a flow entry.
|
PortVlan |
getIncomingNetwork()
Return a pair of switch port and VLAN ID which indicates the incoming
network.
|
Inet4Packet |
getInet4Packet()
Return an
Inet4Packet instance which represents the IPv4 packet
in the payload. |
InetHeader |
getInetHeader()
Returns an
InetHeader instance which describes an IP header. |
SalPort |
getIngressPort()
Return a
SalPort instance corresponding to the ingress switch
port. |
String |
getIngressPortName()
Return the name of the ingress switch port.
|
InventoryReader |
getInventoryReader()
Return the inventory reader associated with the current MD-SAL datastoren
transaction.
|
L4Packet |
getL4Packet()
Return a
L4Packet instance which represents layer 4 protocol
data. |
Layer4Header |
getLayer4Header()
Returns a
Layer4Header instance which describes a layer 4
protocol header. |
int |
getMaxRedirections()
Return the maximum number of flow redirections.
|
VTNManagerProvider |
getProvider()
Return the VTN Manager provider.
|
RouteResolver |
getRouteResolver()
Return route resolver for this packet.
|
Ip4Network |
getSenderIp4Address()
Return the IPv4 address associated with the source MAC address.
|
EtherAddress |
getSourceAddress()
Return the source MAC address.
|
TxContext |
getTxContext()
Return a MD-SAL datastore transaction context.
|
int |
getVlanId()
Return VLAN ID of this packet.
|
VNodeReader |
getVNodeReader()
Return the virtual node reader associated with the current MD-SAL
datastore transaction.
|
boolean |
hasMatchField(FlowMatchType type)
Determine whether the given match field will be configured in a flow
entry or not.
|
void |
initPacketIn(TenantNodeIdentifier<?,?> ref)
Initialize the received packet information.
|
void |
installDropFlow()
Install a flow entry that discards the packet.
|
void |
installFlow(SalPort egress,
int outVid,
List<LinkEdge> path)
Install a VTN data flow for the received packet.
|
boolean |
isFilterDisabled()
Determine whether this packet should be handled without flow filters
or not.
|
boolean |
isFiltered()
Determine whether at least one flow filter is evaluated with this packet
or not.
|
boolean |
isFlooding()
Determine whether the packet is going to be broadcasted in the vBridge
or not.
|
boolean |
isIPv4()
Determine whether this packet is an IPv4 packet or not.
|
boolean |
isToController()
Determine whether the destination address of this packet is equal to
the controller address or not.
|
boolean |
isUnicast()
Determine whether this packet is an unicast packet or not.
|
void |
notMapped(RedirectFlowException rex)
Invoked when the physical switch port is not mapped to the destination
virtual interface.
|
void |
probeInetAddress()
Try to probe IP address of the source address of this packet.
|
boolean |
redirect(VInterfaceIdentifier<?> path,
RedirectFlowException rex)
Record the packet redirection.
|
void |
removeFilterAction(Class<? extends FlowFilterAction> actClass)
Remove the specified flow action from the flow filter action list.
|
void |
removeFlows(MacEntry ment)
Purge VTN flows relevant to the given obsolete layer 2 host.
|
void |
setEgressVNodeHop(VNodeHop vhop)
Set the virtual node hop to the egress node.
|
boolean |
setFirstRedirection(RedirectFlowException rex)
Set a
RedirectFlowException which represents the first packet
redirection in a flow. |
void |
setFlooding(boolean b)
Set a boolean value which indicates whether the packet is going to
be broadcasted in the vBridge.
|
void |
setFlowTimeout(int idle,
int hard)
Set timeout for the ingress flow.
|
void |
setToController(boolean b)
Set a boolean value which indicates whether the packet is sent to the
controller or not.
|
void |
setVlanId(int vid)
Set VLAN ID used for packet matching.
|
void |
transmit(SalPort egress,
Packet packet)
Transmit the given packet.
|
public PacketContext(PacketInEvent ev)
ev
- A PacketInEvent
instance.public void initPacketIn(TenantNodeIdentifier<?,?> ref)
ref
- A TenantNodeIdentifier
instance that specifies the
virtual mapping that maps the packet.public Ethernet getFrame()
public EtherPacket getEtherPacket()
EtherPacket
instance which represents the Ethernet
frame.EtherPacket
instance.public EtherAddress getSourceAddress()
public EtherAddress getDestinationAddress()
public Ip4Network getSenderIp4Address()
Ip4Network
instance that indicates the sender
IPv4 address if found. null
if not found.public SalPort getIngressPort()
SalPort
instance corresponding to the ingress switch
port.SalPort
instance.public String getIngressPortName() throws VTNException
null
if not available.VTNException
- An error occurred.public PortVlan getIncomingNetwork()
PortVlan
which indicates the incoming network where
the packet was received from.public int getVlanId()
public Ethernet createFrame(int vlan) throws VTNException
vlan
- VLAN ID for a new frame.
Zero means that the VLAN tag should not be added.VTNException
- Failed to commit packet modification.public void removeFlows(MacEntry ment)
ment
- An obsolete MAC address table entry.public String getDescription(SalPort sport)
sport
- A SalPort
instance associated with the ethernet
frame.public String getDescription(Ethernet ether, SalPort sport, int vid)
ether
- An ethernet frame.sport
- A SalPort
instance associated with the ethernet
frame.vid
- VLAN ID.public String getDescription(EtherAddress src, EtherAddress dst, int type, SalPort sport, int vid)
src
- The source MAC address.dst
- The destination MAC address.type
- The ethernet type.sport
- A SalPort
instance associated with the ethernet
frame.vid
- VLAN ID.public Inet4Packet getInet4Packet()
Inet4Packet
instance which represents the IPv4 packet
in the payload.Inet4Packet
instance if the Ethernet frame contains
an IPv4 paclet. Otherwise null
.public L4Packet getL4Packet()
L4Packet
instance which represents layer 4 protocol
data.L4Packet
instance if found.
null
if not found.public boolean isIPv4()
true
is returned only if this packet is an IPv4 packet.public boolean isUnicast()
true
is returned only if this packet is an unicast
packet.public void probeInetAddress()
public void addVNodeHop(VNodeHop vhop)
vhop
- A VNodeHop
instance which represents a routing
to the virtual node.public void setEgressVNodeHop(VNodeHop vhop)
vhop
- A VNodeHop
instance which represents the hop to
the egress node.public VNodeHop getEgressVNodeHop()
VNodeHop
instance which represents the virtual node
hop to the egress node.VNodeHop
instance.
null
is returned if not configured.public RouteResolver getRouteResolver()
RouteResolver
instance.public int getIdleTimeout()
public int getHardTimeout()
public int getBaseFlowPriority()
public int getMaxRedirections()
public int getFlowPriority()
public void installFlow(SalPort egress, int outVid, List<LinkEdge> path)
public void commit() throws VTNException
VTNException
- Failed to copy the packet.public void setFlooding(boolean b)
b
- true
means that the packet is going to be broadcasted
in the vBridge.public boolean isFilterDisabled()
true
is returned only if flow filters should be
disabled.public boolean isFiltered()
true
only if at least one flow filter is evaluated.public boolean isToController()
true
is returned if this packet is sent to the
controller. Otherwise false
is returned.public void setToController(boolean b)
b
- true
means that the packet is sent to the controller.
Pass false
otherwise.public boolean redirect(VInterfaceIdentifier<?> path, RedirectFlowException rex)
path
- The location of the destination interface.rex
- A RedirectFlowException
instance that keeps
information about packet redirection.true
if the packet should be forwarded to the
destination interface.
false
if the packet should be discarded.public RedirectFlowException getFirstRedirection()
RedirectFlowException
which represents the first packet
redirection in a flow.RedirectFlowException
instance.
null
is returned if the packet was not redirected.public TxContext getTxContext()
TxContext
instance.public EtherAddress getControllerAddress()
EtherAddress
instance that indicates the MAC address
of the controller.public void transmit(SalPort egress, Packet packet)
The given packet is enqueued to the packet transmission queue, and will be transmitted when the MD-SAL datastore transaction completes successfully.
public void addFlow(VTNFlowBuilder builder)
The given data flow is enqueued to the flow installation request queue, and it will be installed when the MD-SAL datastore transaction completes successfully.
builder
- A VTNFlowBuilder
instance which contains
data flow to be installed.public VNodeReader getVNodeReader()
VNodeReader
instance.public PacketContext evaluate(FlowFilterList fflist, int vid) throws DropFlowException, RedirectFlowException
fflist
- A FlowFilterList
instance.vid
- A VLAN ID to be used for packet matching.
A VLAN ID configured in the given packet is used if a
negative value is specified.PacketContext
to be used for succeeding packet
processing.DropFlowException
- The given packet was discarded by a flow filter configured in
this instance.RedirectFlowException
- The given packet was redirected by a flow filter configured in
this instance.public InventoryReader getInventoryReader()
InventoryReader
instance.public VTNFlowBuilder createFlowBuilder(String tname, VTNMatch vmatch)
Note that this method configures uses the base flow priority.
tname
- The name of the VTN.vmatch
- A VTNMatch
instance.VTNFlowBuilder
instance.public void destinationNotFound(RedirectFlowException rex, String msg)
rex
- A RedirectFlowException
instance.msg
- An error message.public void destinationDisabled(RedirectFlowException rex)
rex
- A RedirectFlowException
instance.public void notMapped(RedirectFlowException rex)
rex
- A RedirectFlowException
instance.public void forwarded(RedirectFlowException rex, VNodeIdentifier<?> to, SalPort sport, int vid)
rex
- A RedirectFlowException
instance.to
- The identifier for the egress virtual node.sport
- A SalPort
corresponding to the outgoing physical
switch port.vid
- A VLAN ID to be set to the outgoing packet.public void broadcasted(RedirectFlowException rex, VNodeIdentifier<?> ident)
rex
- A RedirectFlowException
instance.ident
- The identifier for the virtual node where the packet
was broadcasted.public PacketContext clone()
public void addMatchField(FlowMatchType type)
addMatchField
in interface FlowMatchContext
type
- A match type to be added.public boolean hasMatchField(FlowMatchType type)
hasMatchField
in interface FlowMatchContext
type
- A match type to be tested.true
only if the given match type will be configured
in a flow entry.public void addUnicastMatchFields()
addUnicastMatchFields
in interface FlowMatchContext
public EtherHeader getEtherHeader()
EtherHeader
instance which describes an Ethernet
header and IEEE 802.1Q VLAN tag.getEtherHeader
in interface PacketHeader
EtherHeader
instance.public InetHeader getInetHeader()
InetHeader
instance which describes an IP header.getInetHeader
in interface PacketHeader
InetHeader
instance if a packet associated with
this instance is an IP packet. Otherwise null
.public Layer4Header getLayer4Header()
Layer4Header
instance which describes a layer 4
protocol header.getLayer4Header
in interface PacketHeader
Layer4Header
instance if a packet associated with
this instance contains a layer 4 protocol header.
Otherwise null
.public String getHeaderDescription()
getHeaderDescription
in interface PacketHeader
public void addFilterAction(FlowFilterAction act)
This method is used to apply flow actions configured in a flow filter.
addFilterAction
in interface FlowActionContext
act
- A FlowFilterAction
instance.public void removeFilterAction(Class<? extends FlowFilterAction> actClass)
removeFilterAction
in interface FlowActionContext
actClass
- A class of flow action to be removed.public Collection<FlowFilterAction> getFilterActions()
getFilterActions
in interface FlowActionContext
null
is returned if no flow action was created by
flow filter.public VTNManagerProvider getProvider()
getProvider
in interface PathMapContext
VTNManagerProvider
instance.public FlowCondReader getFlowCondReader()
getFlowCondReader
in interface PathMapContext
FlowCondReader
instance.public void setFlowTimeout(int idle, int hard)
setFlowTimeout
in interface PathMapContext
idle
- An idle timeout for the ingress flow.hard
- A hard timeout for the ingress flow.public String getDescription()
getDescription
in interface PathMapContext
getDescription
in interface FlowFilterContext
public boolean isFlooding()
isFlooding
in interface FlowFilterContext
true
is returned only if the packet is going to be
broadcasted in the vBridge.public void setVlanId(int vid)
setVlanId
in interface FlowFilterContext
vid
- A VLAN ID.public void installDropFlow()
installDropFlow
in interface FlowFilterContext
public VTNFlowCondition getFlowCondition(VTNFlowFilter ff) throws UnsupportedPacketException
VTNFlowCondition
instance which determines whether the
specified flow filter needs to be applied to the packet.
Note that this method also checks whether this flow filter supports the given packet or not.
getFlowCondition
in interface FlowFilterContext
ff
- A VTNFlowFilter
instance.VTNFlowCondition
instance which selects the packet.UnsupportedPacketException
- The specified flow filter does not support the given packet.public boolean setFirstRedirection(RedirectFlowException rex)
RedirectFlowException
which represents the first packet
redirection in a flow.setFirstRedirection
in interface FlowFilterContext
rex
- An RedirectFlowException
instance.true
if the given instance represents the first packet
redirection in a flow.
false
otherwise.Copyright © 2018 OpenDaylight. All rights reserved.