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 |
private OFProtocol |
protocol |
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 |
clearRules()
Delete all the rules from 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() |
protected int |
getInputPort(org.openflow.protocol.interfaces.OFPacketIn pi) |
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.interfaces.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.interfaces.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, registerModule
private 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
private OFProtocol protocol
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()
protected int getInputPort(org.openflow.protocol.interfaces.OFPacketIn pi)
private boolean processPacketInMessage(IOFSwitch sw, org.openflow.protocol.interfaces.OFPacketIn pi, IRoutingDecision decision, MessageContext cntx)
sw
- the switch instancepi
- packetindecision
- the routing decisioncntx
- the MessageContext
protected RuleWildcardsPair matchWithRule(IOFSwitch sw, org.openflow.protocol.interfaces.OFPacketIn pi, MessageContext cntx)
sw
- the switch instancepi
- packetincntx
- the MessageContext
protected 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 OFModule
protected boolean handleHandshakedEvent(Connection conn, MessageContext context)
OFModule
OFModule.processHandshakeFinished(Connection, MessageContext)
.
Normally, most of modules have very simple implementation for this method,
only returning true.handleHandshakedEvent
in class OFModule
conn
- 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)
OFModule
OFModule.processMessage(Connection, MessageContext, OFMessage, List)
.handleMessage
in class OFModule
conn
- 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)
OFModule
OFModule.processDisconnect(Connection)
.
All subclasses of OFModule should implement this method.handleDisconnect
in class OFModule
conn
- connection that the event has occurredpublic OFModel[] getModels()
OFModule
OFModel
objects associated with this module.
Normally the size of the array is one, but not limited to.public void enableFirewall(boolean enabled)
IFirewallService
enableFirewall
in interface IFirewallService
enabled
- true when enabled, false when disabledpublic boolean isEnabled()
IFirewallService
isEnabled
in interface IFirewallService
public java.util.List<FirewallRule> getRules()
IFirewallService
getRules
in interface IFirewallService
public java.lang.String getSubnetMask()
IFirewallService
getSubnetMask
in interface IFirewallService
public void setSubnetMask(java.lang.String newMask)
IFirewallService
setSubnetMask
in interface IFirewallService
newMask
- The new subnet maskpublic java.util.List<java.util.Map<java.lang.String,java.lang.Object>> getStorageRules()
IFirewallService
getStorageRules
in interface IFirewallService
public void addRule(FirewallRule rule)
IFirewallService
addRule
in interface IFirewallService
rule
- a new firewall rulepublic void deleteRule(int ruleid)
IFirewallService
deleteRule
in interface IFirewallService
ruleid
- the ruleid of firewall rule to deletepublic void clearRules()
IFirewallService
clearRules
in interface IFirewallService