public class PortFactory extends AbstractFactory
Port
instances.Modifier and Type | Field and Description |
---|---|
static String |
E_BAD_PORT_NUM
Exception message for invalid port number.
|
Modifier and Type | Method and Description |
---|---|
static Port |
copy(Port p)
Returns a copy (immutable) of the given port.
|
static MutablePort |
createPort(ProtocolVersion pv)
Creates a mutable port.
|
static void |
encodePort(Port port,
OfPacketWriter pkt)
Encodes the specified port structure into the specified buffer.
|
static void |
encodePortList(List<Port> ports,
OfPacketWriter pkt)
Encodes a list of ports, writing them into the supplied buffer.
|
static void |
encodePortNumber(BigPortNumber port,
OfPacketWriter pkt,
ProtocolVersion pv)
Encodes the given port number, writing it to the specified buffer,
for the given protocol version.
|
static int |
getPortLength(ProtocolVersion pv)
Returns the length of a port structure in bytes.
|
static MutablePort |
mutableCopy(Port p)
Returns a mutable copy of the given port.
|
static Port |
parsePort(OfPacketReader pkt,
ProtocolVersion pv)
Parses the given packet buffer as a port structure.
|
static List<Port> |
parsePortList(OfPacketReader pkt,
ProtocolVersion pv)
Parses a list of port structures from the supplied buffer.
|
static BigPortNumber |
parsePortNumber(OfPacketReader pkt,
ProtocolVersion pv)
Parses a port number from the specified buffer, for the given
protocol version.
|
protected String |
tag()
Returns an identifying tag for the port factory.
|
static String |
toDebugString(int indent,
List<Port> ports)
Outputs a list of ports in debug string format.
|
static String |
toDebugString(List<Port> ports)
Outputs a list of ports in debug string format.
|
mpe, mpe, mpe, mpe
public static final String E_BAD_PORT_NUM
protected String tag()
tag
in class AbstractFactory
public static List<Port> parsePortList(OfPacketReader pkt, ProtocolVersion pv) throws MessageParseException
Note that this method causes the reader index of the underlying packet reader to be advanced by the length of the list, which should leave the reader index at the target index.
This method delegates to parsePort(com.hp.of.lib.OfPacketReader, com.hp.of.lib.ProtocolVersion)
for each individual port.
pkt
- the data bufferpv
- the protocol versionMessageParseException
- if unable to parse the structurepublic static Port parsePort(OfPacketReader pkt, ProtocolVersion pv) throws MessageParseException
pkt
- the packet bufferpv
- the protocol versionMessageParseException
- if a problem parsing the bufferpublic static BigPortNumber parsePortNumber(OfPacketReader pkt, ProtocolVersion pv)
Note that, for v1.0, "special" port numbers are translated into their u32 counterparts and returned.
pkt
- the data buffer from which the port is to be readpv
- the protocol versionIllegalArgumentException
- if the parsed port is not valid for
the specified protocol versionPort
public static MutablePort createPort(ProtocolVersion pv)
pv
- the required protocol versionVersionNotSupportedException
- if the version is not supportedpublic static void encodePort(Port port, OfPacketWriter pkt) throws IncompleteStructureException
Note that, for v1.0 ports, "special" port numbers are translated to their u16 counterparts.
port
- the port to encodepkt
- the buffer to write intoIllegalArgumentException
- if the port is mutable, or if the
protocol version is 1.0 and the port number is not u16IncompleteStructureException
- if the port is
missing required fieldspublic static void encodePortNumber(BigPortNumber port, OfPacketWriter pkt, ProtocolVersion pv)
port
argument is null, the bytes are zero-filled.
Note that, for v1.0, "special" port numbers are translated to their u16 counterparts.
port
- the port number to encodepkt
- the data buffer into which the port is to be writtenpv
- the protocol versionPort
public static void encodePortList(List<Port> ports, OfPacketWriter pkt) throws IncompleteStructureException
PacketBuffer
to be advanced by the length of the written
ports.ports
- the list of portspkt
- the buffer into which the ports are to be writtenIncompleteStructureException
- if any of the ports are
missing required fieldspublic static Port copy(Port p)
p
- the original portpublic static MutablePort mutableCopy(Port p)
p
- the original portpublic static int getPortLength(ProtocolVersion pv)
pv
- the protocol versionpublic static String toDebugString(List<Port> ports)
ports
- the list of portsCopyright © 2015. All Rights Reserved.