public class OFMFirewall extends OFModule implements IFirewallService
Modified the original Firewall class of Floodlight.
| Modifier and Type | Field and Description |
|---|---|
private java.lang.String |
collectionName |
static java.lang.String |
COLUMN_ACTION |
static java.lang.String |
COLUMN_DL_DST |
static java.lang.String |
COLUMN_DL_SRC |
static java.lang.String |
COLUMN_DL_TYPE |
static java.lang.String |
COLUMN_DPID |
static java.lang.String |
COLUMN_IN_PORT |
static java.lang.String |
COLUMN_NW_DST_MASKBITS |
static java.lang.String |
COLUMN_NW_DST_PREFIX |
static java.lang.String |
COLUMN_NW_PROTO |
static java.lang.String |
COLUMN_NW_SRC_MASKBITS |
static java.lang.String |
COLUMN_NW_SRC_PREFIX |
static java.lang.String |
COLUMN_PRIORITY |
static java.lang.String |
COLUMN_RULEID |
static java.lang.String |
COLUMN_TP_DST |
static java.lang.String |
COLUMN_TP_SRC |
static java.lang.String |
COLUMN_WILDCARD_DL_DST |
static java.lang.String |
COLUMN_WILDCARD_DL_SRC |
static java.lang.String |
COLUMN_WILDCARD_DL_TYPE |
static java.lang.String |
COLUMN_WILDCARD_DPID |
static java.lang.String |
COLUMN_WILDCARD_IN_PORT |
static java.lang.String |
COLUMN_WILDCARD_NW_DST |
static java.lang.String |
COLUMN_WILDCARD_NW_PROTO |
static java.lang.String |
COLUMN_WILDCARD_NW_SRC |
static java.lang.String |
COLUMN_WILDCARD_TP_DST |
static java.lang.String |
COLUMN_WILDCARD_TP_SRC |
static java.lang.String[] |
ColumnNames |
private java.lang.String |
dbName |
protected boolean |
enabled |
private FirewallStorage |
firewallStorage |
protected java.util.List<FirewallRule> |
rules |
private OFMStorageManager |
storageInstance |
protected int |
subnet_mask |
static java.lang.String |
TABLE_NAME |
controller| Constructor and Description |
|---|
OFMFirewall() |
| Modifier and Type | Method and Description |
|---|---|
void |
addRule(FirewallRule rule)
Adds a new firewall rule into the memory storage and the persistent database.
|
void |
deleteRule(int ruleid)
Deletes the firewall rule using the ruleid from the memory storage
and the persistent database.
|
void |
enableFirewall(boolean enabled)
Enables/disables the firewall.
|
java.lang.String |
getCollectionName() |
java.lang.String |
getDbName() |
OFModel[] |
getModels()
returns the array of all
OFModel objects associated with this module. |
java.util.List<FirewallRule> |
getRules()
Returns all firewall rules.
|
OFMStorageManager |
getStorageInstance() |
java.util.List<java.util.Map<java.lang.String,java.lang.Object>> |
getStorageRules()
Returns all firewall rules of the persistent database.
|
java.lang.String |
getSubnetMask()
Returns the subnet mask.
|
protected boolean |
handleDisconnect(Connection conn)
Process the disconnection event from a switch.
|
protected boolean |
handleHandshakedEvent(Connection conn,
MessageContext context)
An abstract method that all subclasses should implement.
|
protected boolean |
handleMessage(Connection conn,
MessageContext context,
org.openflow.protocol.OFMessage msg,
java.util.List<org.openflow.protocol.OFMessage> outgoing)
Handle incoming messages that pass the test of filters.
|
protected void |
initialize()
Initializes this module.
|
protected boolean |
IPIsBroadcast(int IPAddress)
Checks whether an IP address is a broadcast address or not.
|
boolean |
isEnabled()
Returns operational status of the firewall.
|
protected RuleWildcardsPair |
matchWithRule(IOFSwitch sw,
org.openflow.protocol.OFPacketIn pi,
MessageContext cntx)
Iterates over the firewall rules and tries to match them with the
incoming packet (flow).
|
private boolean |
processPacketInMessage(IOFSwitch sw,
org.openflow.protocol.OFPacketIn pi,
IRoutingDecision decision,
MessageContext cntx)
Checks the incoming packet with the firewall policy and create
a decision to handle the packet.
|
protected java.util.ArrayList<FirewallRule> |
readRulesFromStorage()
Reads the rules from the persistent database and creates a sorted
array list of
FirewallRule. |
void |
setSubnetMask(java.lang.String newMask)
Sets the subnet mask
|
getController, getModule, init, processDisconnect, processHandshakeFinished, processMessage, registerFilter, registerModuleprivate FirewallStorage firewallStorage
private OFMStorageManager storageInstance
private java.lang.String dbName
private java.lang.String collectionName
protected java.util.List<FirewallRule> rules
protected boolean enabled
protected int subnet_mask
public static final java.lang.String TABLE_NAME
public static final java.lang.String COLUMN_RULEID
public static final java.lang.String COLUMN_DPID
public static final java.lang.String COLUMN_IN_PORT
public static final java.lang.String COLUMN_DL_SRC
public static final java.lang.String COLUMN_DL_DST
public static final java.lang.String COLUMN_DL_TYPE
public static final java.lang.String COLUMN_NW_SRC_PREFIX
public static final java.lang.String COLUMN_NW_SRC_MASKBITS
public static final java.lang.String COLUMN_NW_DST_PREFIX
public static final java.lang.String COLUMN_NW_DST_MASKBITS
public static final java.lang.String COLUMN_NW_PROTO
public static final java.lang.String COLUMN_TP_SRC
public static final java.lang.String COLUMN_TP_DST
public static final java.lang.String COLUMN_WILDCARD_DPID
public static final java.lang.String COLUMN_WILDCARD_IN_PORT
public static final java.lang.String COLUMN_WILDCARD_DL_SRC
public static final java.lang.String COLUMN_WILDCARD_DL_DST
public static final java.lang.String COLUMN_WILDCARD_DL_TYPE
public static final java.lang.String COLUMN_WILDCARD_NW_SRC
public static final java.lang.String COLUMN_WILDCARD_NW_DST
public static final java.lang.String COLUMN_WILDCARD_NW_PROTO
public static final java.lang.String COLUMN_WILDCARD_TP_SRC
public static final java.lang.String COLUMN_WILDCARD_TP_DST
public static final java.lang.String COLUMN_PRIORITY
public static final java.lang.String COLUMN_ACTION
public static java.lang.String[] ColumnNames
public OFMStorageManager getStorageInstance()
public java.lang.String getDbName()
public java.lang.String getCollectionName()
private boolean processPacketInMessage(IOFSwitch sw, org.openflow.protocol.OFPacketIn pi, IRoutingDecision decision, MessageContext cntx)
sw - the switch instancepi - packetindecision - the routing decisioncntx - the MessageContextprotected RuleWildcardsPair matchWithRule(IOFSwitch sw, org.openflow.protocol.OFPacketIn pi, MessageContext cntx)
sw - the switch instancepi - packetincntx - the MessageContextprotected boolean IPIsBroadcast(int IPAddress)
IPAddress - the IP address to checkprotected java.util.ArrayList<FirewallRule> readRulesFromStorage()
FirewallRule.
Similar to getStorageRules(), which only reads contents for REST GET
and does no parsing, checking, nor putting into FirewallRule objects.FirewallRule instances
(rules from the database)protected void initialize()
initialize in class OFModuleprotected boolean handleHandshakedEvent(Connection conn, MessageContext context)
OFModuleOFModule.processHandshakeFinished(Connection, MessageContext).
Normally, most of modules have very simple implementation for this method,
only returning true.handleHandshakedEvent in class OFModuleconn - connection that the event has occurredcontext - message context for the handshaking messagesprotected boolean handleMessage(Connection conn, MessageContext context, org.openflow.protocol.OFMessage msg, java.util.List<org.openflow.protocol.OFMessage> outgoing)
OFModuleOFModule.processMessage(Connection, MessageContext, OFMessage, List).handleMessage in class OFModuleconn - connection that the message has arrivedcontext - message context for the messagemsg - the actual message objectoutgoing - responses for the message arrived, which is filled by the handleMessage implementationprotected boolean handleDisconnect(Connection conn)
OFModuleOFModule.processDisconnect(Connection).
All subclasses of OFModule should implement this method.handleDisconnect in class OFModuleconn - connection that the event has occurredpublic OFModel[] getModels()
OFModuleOFModel objects associated with this module.
Normally the size of the array is one, but not limited to.public void enableFirewall(boolean enabled)
IFirewallServiceenableFirewall in interface IFirewallServiceenabled - true when enabled, false when disabledpublic boolean isEnabled()
IFirewallServiceisEnabled in interface IFirewallServicepublic java.util.List<FirewallRule> getRules()
IFirewallServicegetRules in interface IFirewallServicepublic java.lang.String getSubnetMask()
IFirewallServicegetSubnetMask in interface IFirewallServicepublic void setSubnetMask(java.lang.String newMask)
IFirewallServicesetSubnetMask in interface IFirewallServicenewMask - The new subnet maskpublic java.util.List<java.util.Map<java.lang.String,java.lang.Object>> getStorageRules()
IFirewallServicegetStorageRules in interface IFirewallServicepublic void addRule(FirewallRule rule)
IFirewallServiceaddRule in interface IFirewallServicerule - a new firewall rulepublic void deleteRule(int ruleid)
IFirewallServicedeleteRule in interface IFirewallServiceruleid - the ruleid of firewall rule to delete