public class OFProtocol
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private OFController |
controller
reference to OFController object.
|
private java.util.Map<IOFSwitch,java.util.Map<java.lang.Integer,PortInformation>> |
portInformations
Port Number to PortInformation map.
|
private java.util.Map<IOFSwitch,java.util.Map<java.lang.String,PortInformation>> |
portInformationsByName
Switch to
|
private java.lang.Object |
portLock
lock to synchronize.
|
private java.util.Map<IOFSwitch,java.util.Map<java.lang.Integer,java.lang.Object>> |
responsesCache
This field is used to exchange information with switch.
|
static java.lang.String |
STR_DL_DST |
static java.lang.String |
STR_DL_SRC |
static java.lang.String |
STR_DL_TYPE |
static java.lang.String |
STR_DL_VLAN |
static java.lang.String |
STR_DL_VLAN_PCP |
static java.lang.String |
STR_IN_PORT |
static java.lang.String |
STR_NW_DST |
static java.lang.String |
STR_NW_PROTO |
static java.lang.String |
STR_NW_SRC |
static java.lang.String |
STR_NW_TOS |
static java.lang.String |
STR_TP_DST |
static java.lang.String |
STR_TP_SRC |
private java.util.Map<IOFSwitch,SwitchInformation> |
switchInformations
IOFSwitch to SwitchInformation map.
|
Constructor and Description |
---|
OFProtocol(OFController controller)
Initialize OFProtocol object with OFController reference.
|
Modifier and Type | Method and Description |
---|---|
private PortInformation |
createPortInformation(IOFSwitch sw,
int port) |
void |
deletePort(IOFSwitch sw,
int portNumber)
Delete port information by the number
|
private void |
deliverFeaturesReply(IOFSwitch sw,
int xid,
org.openflow.protocol.interfaces.OFFeaturesReply reply) |
private void |
deliverSwitchStatistics(IOFSwitch sw,
org.openflow.protocol.interfaces.OFStatisticsReply m) |
OFController |
getController()
Get reference to OFController object.
|
org.openflow.protocol.interfaces.OFStatisticsDescReply |
getDescription(IOFSwitch sw)
Get switch description as a OFStatisticsDescReply form
|
java.util.Collection<java.lang.Integer> |
getEnabledPortNumbers(IOFSwitch sw)
Get all the enabled port numbers
|
java.util.Collection<org.openflow.protocol.interfaces.OFPortDesc> |
getEnabledPorts(IOFSwitch sw)
Get all the enabled ports
|
org.openflow.protocol.interfaces.OFFeaturesReply |
getFeaturesReply(IOFSwitch sw)
Get OFFeaturesReply for the given switch.
|
org.openflow.protocol.interfaces.OFPortDesc |
getPort(IOFSwitch sw,
int portNum)
Get port description as an OFPortDesc object
|
PortInformation |
getPortInformation(IOFSwitch sw,
int port)
Get port information by the port number.
|
PortInformation |
getPortInformationByName(IOFSwitch sw,
java.lang.String name)
This method should be called after port number is correctly set up.
|
java.util.Collection<PortInformation> |
getPortInformations(IOFSwitch sw)
Get all PortInformation objects for the given switch
|
java.util.Collection<PortInformation> |
getPortInformations(long datapathId)
Get all the PortInformation objects for the given switch by datapath id
|
java.util.Collection<org.openflow.protocol.interfaces.OFPortDesc> |
getPorts(IOFSwitch sw)
Get all port information as a collection of OFPortDesc objects
|
java.util.List<org.openflow.protocol.interfaces.OFPortDesc> |
getPorts(long datapathId)
Get all port information as a list of OFPortDesc objects (TODO: why not collection?)
|
java.lang.Object |
getResponseCacheItem(IOFSwitch sw,
int xid)
This method is used with two other companion methods: setResponseCacheItem and removeResponseCacheItem.
|
SwitchInformation |
getSwitchInformation(IOFSwitch sw)
Get switch information
|
java.util.List<org.openflow.protocol.interfaces.OFStatisticsReply> |
getSwitchStatistics(IOFSwitch sw,
org.openflow.protocol.interfaces.OFStatisticsRequest req)
Modules that use IOFSwitch objects use this method to request statistics to the switch.
|
boolean |
handleConnectedEvent(Connection conn)
Callback called by underlying platform when a connection to a switch is established
|
org.openflow.protocol.interfaces.OFMatch |
loadOFMatchFromPacket(IOFSwitch sw,
byte[] packetData,
short inputPort)
Create an OFMatch object from the packet-in data.
|
org.openflow.protocol.interfaces.OFMatch |
loadOFMatchFromString(IOFSwitch sw,
java.lang.String match)
Set this OFMatch's parameters based on a comma-separated key=value pair
dpctl-style string, e.g., from the output of OFMatch.toString()
Supported keys/values include KEY(s) VALUE "in_port","input_port" integer "dl_src","eth_src", "dl_dst","eth_dst" hex-string "dl_type", "dl_vlan", "dl_vlan_pcp" integer "nw_src", "nw_dst", "ip_src", "ip_dst" CIDR-style netmask "tp_src","tp_dst" integer (max 64k) The CIDR-style netmasks assume 32 netmask if none given, so: "128.8.128.118/32" is the same as "128.8.128.118" |
boolean |
portEnabled(IOFSwitch sw,
short port)
Check if a given port is enabled
|
boolean |
portEnabled(org.openflow.protocol.interfaces.OFPortDesc port)
Check if the given port is enabled
|
boolean |
process(Connection conn,
MessageContext context,
org.openflow.protocol.OFMessage m)
Callback called by underlying platform when a new OFMessage is received for a connection
|
void |
removePortInformation(IOFSwitch sw,
PortInformation pi)
Remove a specific port information from the switch
|
void |
removeResponseCacheItem(IOFSwitch sw,
int xid)
This method is used with two other companion methods: setResponseCacheItem and getResponseCacheItem.
|
void |
setDescription(IOFSwitch sw,
org.openflow.protocol.interfaces.OFStatisticsDescReply r)
Modify switch description using OFStatisticsDescReply object
|
private void |
setFromCIDR(org.openflow.protocol.interfaces.OFMatch.Builder match,
java.lang.String cidr,
java.lang.String which)
Set the networkSource or networkDestionation address and their wildcards
from the CIDR string
|
void |
setPort(IOFSwitch sw,
org.openflow.protocol.interfaces.OFPortDesc portDesc)
Set port information using OFPortDesc object
|
void |
setPortInformationByName(IOFSwitch sw,
java.lang.String name,
PortInformation pi)
Set the port information
|
void |
setResponseCacheItem(IOFSwitch sw,
int xid,
java.lang.Object item)
This method is used with two other companion methods: getResponseCacheItem and removeResponseCacheItem.
|
public static final java.lang.String STR_IN_PORT
public static final java.lang.String STR_DL_DST
public static final java.lang.String STR_DL_SRC
public static final java.lang.String STR_DL_TYPE
public static final java.lang.String STR_DL_VLAN
public static final java.lang.String STR_DL_VLAN_PCP
public static final java.lang.String STR_NW_DST
public static final java.lang.String STR_NW_SRC
public static final java.lang.String STR_NW_PROTO
public static final java.lang.String STR_NW_TOS
public static final java.lang.String STR_TP_DST
public static final java.lang.String STR_TP_SRC
private java.util.Map<IOFSwitch,SwitchInformation> switchInformations
private java.util.Map<IOFSwitch,java.util.Map<java.lang.Integer,PortInformation>> portInformations
private java.util.Map<IOFSwitch,java.util.Map<java.lang.String,PortInformation>> portInformationsByName
private java.util.Map<IOFSwitch,java.util.Map<java.lang.Integer,java.lang.Object>> responsesCache
private OFController controller
private java.lang.Object portLock
public OFProtocol(OFController controller)
controller
- OFController object.public OFController getController()
public void setResponseCacheItem(IOFSwitch sw, int xid, java.lang.Object item)
sw
- IOFSwitch objectxid
- transaction iditem
- object to set as a response for the transaction idpublic java.lang.Object getResponseCacheItem(IOFSwitch sw, int xid)
sw
- IOFSwitch objectxid
- transaction id to get the response objectpublic void removeResponseCacheItem(IOFSwitch sw, int xid)
sw
- IOFSwitch objectxid
- transaction id to remove the response objectpublic SwitchInformation getSwitchInformation(IOFSwitch sw)
sw
- Switch to retrieve the SwitchInformation objectpublic PortInformation getPortInformation(IOFSwitch sw, int port)
sw
- Switch to retrieve the port informationport
- port number to retrieve the informationpublic java.util.Collection<PortInformation> getPortInformations(IOFSwitch sw)
sw
- IOFSwitch objectpublic java.util.Collection<PortInformation> getPortInformations(long datapathId)
datapathId
- datapath id of the switchpublic void removePortInformation(IOFSwitch sw, PortInformation pi)
sw
- IOFSwitch objectpi
- PortInformation objectpublic PortInformation getPortInformationByName(IOFSwitch sw, java.lang.String name)
sw
- IOFSwitch objectname
- name of the portpublic void setPortInformationByName(IOFSwitch sw, java.lang.String name, PortInformation pi)
sw
- IOFSwitch objectname
- port namepi
- PortInformation objectpublic void setDescription(IOFSwitch sw, org.openflow.protocol.interfaces.OFStatisticsDescReply r)
sw
- IOFswitch objectr
- OFStatisticsDescReply objectpublic org.openflow.protocol.interfaces.OFStatisticsDescReply getDescription(IOFSwitch sw)
sw
- IOFSwitch objectpublic org.openflow.protocol.interfaces.OFPortDesc getPort(IOFSwitch sw, int portNum)
sw
- IOFSwitch objectportNum
- port numberpublic java.util.Collection<org.openflow.protocol.interfaces.OFPortDesc> getPorts(IOFSwitch sw)
sw
- IOFSwitch objectpublic java.util.List<org.openflow.protocol.interfaces.OFPortDesc> getPorts(long datapathId)
datapathId
- datapath id (long)public void setPort(IOFSwitch sw, org.openflow.protocol.interfaces.OFPortDesc portDesc)
sw
- IOFSwitch objectportDesc
- OFPortDesc objectprivate PortInformation createPortInformation(IOFSwitch sw, int port)
public void deletePort(IOFSwitch sw, int portNumber)
sw
- IOFSwitch objectportNumber
- number of the portpublic boolean handleConnectedEvent(Connection conn)
conn
- Connection objectpublic boolean process(Connection conn, MessageContext context, org.openflow.protocol.OFMessage m)
conn
- Connection objectcontext
- MessageContext object created for the messagem
- OFMessage object to handlepublic java.util.List<org.openflow.protocol.interfaces.OFStatisticsReply> getSwitchStatistics(IOFSwitch sw, org.openflow.protocol.interfaces.OFStatisticsRequest req)
req
- OFStatisticsRequest object.private void deliverSwitchStatistics(IOFSwitch sw, org.openflow.protocol.interfaces.OFStatisticsReply m)
public org.openflow.protocol.interfaces.OFFeaturesReply getFeaturesReply(IOFSwitch sw)
sw
- IOFSwitch objectprivate void deliverFeaturesReply(IOFSwitch sw, int xid, org.openflow.protocol.interfaces.OFFeaturesReply reply)
public java.util.Collection<org.openflow.protocol.interfaces.OFPortDesc> getEnabledPorts(IOFSwitch sw)
sw
- IOFSwitch objectpublic java.util.Collection<java.lang.Integer> getEnabledPortNumbers(IOFSwitch sw)
sw
- IOFSwitch objectpublic boolean portEnabled(org.openflow.protocol.interfaces.OFPortDesc port)
port
- OFPortDesc objectpublic boolean portEnabled(IOFSwitch sw, short port)
sw
- IOFSwitch object to which the port is boundport
- port number (short)public org.openflow.protocol.interfaces.OFMatch loadOFMatchFromPacket(IOFSwitch sw, byte[] packetData, short inputPort)
sw
- IOFSwitch objectpacketData
- packet-in data arrayinputPort
- input port (short)private void setFromCIDR(org.openflow.protocol.interfaces.OFMatch.Builder match, java.lang.String cidr, java.lang.String which) throws java.lang.IllegalArgumentException
cidr
- "192.168.0.0/16" or "172.16.1.5"which
- one of STR_NW_DST or STR_NW_SRCjava.lang.IllegalArgumentException
public org.openflow.protocol.interfaces.OFMatch loadOFMatchFromString(IOFSwitch sw, java.lang.String match) throws java.lang.IllegalArgumentException
KEY(s) | VALUE |
"in_port","input_port" | integer |
"dl_src","eth_src", "dl_dst","eth_dst" | hex-string |
"dl_type", "dl_vlan", "dl_vlan_pcp" | integer |
"nw_src", "nw_dst", "ip_src", "ip_dst" | CIDR-style netmask |
"tp_src","tp_dst" | integer (max 64k) |
match
- a key=value comma separated string, e.g.
"in_port=5,ip_dst=192.168.0.0/16,tp_src=80"java.lang.IllegalArgumentException
- on unexpected key or value