public class Port extends OpenflowStructure
Instances of this class are immutable.
In OpenFlow, ports are numbered starting from 1. The maximum legal value
for an individual port is MAX
(but see below).
Reserved OpenFlow Port numbers (fake output "ports") are also defined
on this class:
IN_PORT
- Send packet out the input port.TABLE
- Submit the packet to the first flow table.NORMAL
- Process with normal L2/L3 switching.FLOOD
- All physical ports in VLAN (with exceptions).ALL
- All physical ports except input port.CONTROLLER
- Send to the controller.LOCAL
- Local openflow "port".ANY
- Wildcard port used only for flow mod (delete) and
flow stats requests.
Note that in OpenFlow version 1.0, port numbers were defined as
unsigned 16-bit (u16) values; Since version 1.1 port numbers have been
defined as unsigned 32-bit (u32) values. Since this class represents
ports spanning all versions of the protocol, the port number is expressed
using the BigPortNumber
class. When creating a version 1.0 port,
the value of the port number is validated as u16. Additionally, when
encoding the "special" values (listed above as MAX
, and the
Reserved values), their u16 counterparts are substituted at the
time the port structure is encoded as bytes.
PortFactory
Modifier and Type | Field and Description |
---|---|
static BigPortNumber |
ALL
All physical ports except input port; Since 1.0.
|
static BigPortNumber |
ANY
Wildcard port used only for flow mod (delete) and flow stats
requests; Since 1.1.
|
static BigPortNumber |
CONTROLLER
Send to the Controller; Since 1.0.
|
static BigPortNumber |
FLOOD
All physical ports in VLAN, except input port and those blocked
or link down; Since 1.0.
|
static BigPortNumber |
IN_PORT
Send the packet out the input port; Since 1.0.
|
static BigPortNumber |
LOCAL
Local openflow "port"; Since 1.0.
|
static BigPortNumber |
MAX
Maximum number of physical and logical switch ports; Since 1.0.
|
static BigPortNumber |
NONE
Not associated with a physical port; Since 1.0.
|
static BigPortNumber |
NORMAL
Process with normal L2/L3 switching; Since 1.0.
|
static BigPortNumber |
TABLE
Submit the packet to the first flow table; Since 1.0.
|
parseErrorCause, version
Modifier and Type | Method and Description |
---|---|
static PortNumber |
equivalentSpecial(BigPortNumber bpn)
Returns the 1.0 "special" port number (u16) equivalent to the
given 1.3 "special" big port number (u32).
|
static BigPortNumber |
equivalentSpecial(PortNumber pn)
Returns the 1.3 "special" big port number (u32) equivalent to the
given 1.0 "special" port number (u16).
|
Set<PortFeature> |
getAdvertised()
Returns the set of features advertised by the port; Since 1.0.
|
static BigPortNumber |
getBigPortNumber(String portNumber)
Returns the port, given its string representation, which can include a
logical name or the numeric representation of the port.
|
Set<PortConfig> |
getConfig()
Returns the port administrative settings.
|
Set<PortFeature> |
getCurrent()
Returns the set of current features; Since 1.0.
|
long |
getCurrentSpeed()
Returns the current port speed (bitrate) in kbps; Since 1.1.
|
MacAddress |
getHwAddress()
Returns the MAC address for the port; Since 1.0.
|
String |
getLogicalNumber()
Returns the decimal number of this port, unless this is a "special"
reserved number, in which case the logical name for the port is
returned instead.
|
static String |
getLogicalNumber(BigPortNumber bpn,
ProtocolVersion pv)
Returns either the logical name of the port, if it is a special value,
or the port number as a string.
|
long |
getMaxSpeed()
Returns the maximum port speed (bitrate) in kbps; Since 1.1.
|
String |
getName()
Returns the human readable name for the interface; Since 1.0.
|
Set<PortFeature> |
getPeer()
Returns the set of features advertised by the peer; Since 1.0.
|
BigPortNumber |
getPortNumber()
The port number uniquely identifies a port within a switch; Since 1.0.
|
static PortNumber |
getPortNumber(String portNumber)
Returns the port, given its string representation, which can include a
logical name or the numeric representation of the port.
|
Set<PortState> |
getState()
Returns the state of the physical link or switch protocols
outside of OpenFlow; Since 1.0.
|
Set<PortFeature> |
getSupported()
Returns the set of features supported by the port; Since 1.0.
|
boolean |
isBlocked()
Returns true if this port is prevented from being used for flooding.
|
boolean |
isEnabled()
Returns true if the port is administratively enabled.
|
boolean |
isLinkUp()
Returns true if this port's link is up.
|
static boolean |
isStandardPort(BigPortNumber bpn,
ProtocolVersion pv)
Returns true if the given port number is in the range
1 to MAX; false otherwise.
|
static String |
logicalName(BigPortNumber port,
ProtocolVersion pv)
Returns the logical name of the port, or null if the port number is
not a special value (for the given protocol version).
|
static String |
portNumberToString(BigPortNumber port)
Returns a string representation of the port number.
|
static String |
portNumberToString(BigPortNumber port,
ProtocolVersion pv)
Returns a string representation of the port number, for the given
protocol version.
|
static String |
portNumberToString(PortNumber port)
Returns a string representation of the port number.
|
String |
toDebugString()
Returns a multi-line representation of this port.
|
String |
toDebugString(int indent)
Returns a multi-line representation of this port.
|
String |
toString() |
void |
validate()
Validates this structure for completeness and throws an exception
if the structure is considered "not complete".
|
static void |
validatePortValue(BigPortNumber bpn,
ProtocolVersion pv)
Validates that the given port number is an acceptable value
for encoding as a port number for the given protocol.
|
getVersion, hex, hex, incomplete, parseErrorCause
public static final BigPortNumber MAX
Note: in 1.0, this value is 0xff00
.
public static final BigPortNumber IN_PORT
Note: in 1.0, this value is 0xfff8
.
public static final BigPortNumber TABLE
Note: in 1.0, this value is 0xfff9
.
public static final BigPortNumber NORMAL
Note: in 1.0, this value is 0xfffa
.
public static final BigPortNumber FLOOD
Note: in 1.0, this value is 0xfffb
.
public static final BigPortNumber ALL
Note: in 1.0, this value is 0xfffc
.
public static final BigPortNumber CONTROLLER
Note: in 1.0, this value is 0xfffd
.
public static final BigPortNumber LOCAL
Note: in 1.0, this value is 0xfffe
.
public static final BigPortNumber ANY
See NONE
for 1.0.
public static final BigPortNumber NONE
Note: in 1.0, this value is 0xffff
.
See ANY
for 1.1 and higher.
public String toString()
toString
in class OpenflowStructure
public String toDebugString()
toDebugString
in interface Structure
toDebugString
in class OpenflowStructure
public String toDebugString(int indent)
indent
- depth of indentpublic void validate() throws IncompleteStructureException
OpenflowStructure
This default implementation does nothing, i.e. default behavior is that structures are considered complete.
Subclasses should override this method to check that mandatory fields or other internal state is present, throwing an exception if it is not.
validate
in class OpenflowStructure
IncompleteStructureException
- if the structure is not completepublic BigPortNumber getPortNumber()
public String getLogicalNumber()
public MacAddress getHwAddress()
public String getName()
public Set<PortConfig> getConfig()
public Set<PortState> getState()
public Set<PortFeature> getCurrent()
public Set<PortFeature> getAdvertised()
public Set<PortFeature> getSupported()
public Set<PortFeature> getPeer()
public long getCurrentSpeed()
public long getMaxSpeed()
public boolean isEnabled()
PORT_DOWN
configuration flag.getConfig()
public boolean isLinkUp()
LINK_DOWN
state flag.getState()
public boolean isBlocked()
The "blocked" flag indicates that a switch protocol outside of
OpenFlow, such as 802.1D Spanning Tree, is preventing the use of
the port with FLOOD
.
This convenience method checks for the presence of the
STP_BLOCK
or
BLOCKED
state flag, depending on the
protocol version.
public static String portNumberToString(BigPortNumber port, ProtocolVersion pv)
port
- the port numberpv
- the protocol versionpublic static String portNumberToString(BigPortNumber port)
port
- the port numberpublic static String portNumberToString(PortNumber port)
port
- the port numberpublic static BigPortNumber equivalentSpecial(PortNumber pn)
For example:
BigPortNumber max = Port.equivalentSpecial(Port.MAX_V10); assert(Port.MAX.equals(max));
pn
- the 1.0 special port numberpublic static PortNumber equivalentSpecial(BigPortNumber bpn)
For example:
PortNumber max = Port.equivalentSpecial(Port.MAX); assert(Port.MAX_V10.equals(max));
bpn
- the 1.3 special big port numberpublic static void validatePortValue(BigPortNumber bpn, ProtocolVersion pv)
Note that in 1.0, port numbers are u16.
bpn
- the big port number to validatepv
- the protocol versionIllegalArgumentException
- if the port number is invalid for
the specified versionpublic static boolean isStandardPort(BigPortNumber bpn, ProtocolVersion pv)
bpn
- the port numberpv
- the protocol versionpublic static String logicalName(BigPortNumber port, ProtocolVersion pv)
port
- the port numberpv
- the protocol versionpublic static String getLogicalNumber(BigPortNumber bpn, ProtocolVersion pv)
bpn
- the port numberpv
- the protocol versionpublic static BigPortNumber getBigPortNumber(String portNumber)
portNumber
- string representation of the portpublic static PortNumber getPortNumber(String portNumber)
portNumber
- string representation of the portCopyright © 2015. All Rights Reserved.