public class FirewallRule extends java.lang.Object implements java.lang.Comparable<FirewallRule>, java.io.Serializable
Modifier and Type | Class and Description |
---|---|
static class |
FirewallRule.FirewallAction
This enum constant defines two firewall actions
|
Modifier and Type | Field and Description |
---|---|
FirewallRule.FirewallAction |
action |
long |
dl_dst |
long |
dl_src |
short |
dl_type |
long |
dpid |
short |
in_port |
int |
nw_dst_maskbits |
int |
nw_dst_prefix |
short |
nw_proto |
int |
nw_src_maskbits |
int |
nw_src_prefix |
static short |
OFP_VLAN_NONE |
static int |
OFPFW_ALL |
static int |
OFPFW_DL_DST |
static int |
OFPFW_DL_SRC |
static int |
OFPFW_DL_TYPE |
static int |
OFPFW_DL_VLAN |
static int |
OFPFW_DL_VLAN_PCP |
static int |
OFPFW_IN_PORT |
static int |
OFPFW_NW_DST_ALL |
static int |
OFPFW_NW_DST_BITS |
static int |
OFPFW_NW_DST_MASK |
static int |
OFPFW_NW_DST_SHIFT |
static int |
OFPFW_NW_PROTO |
static int |
OFPFW_NW_SRC_ALL |
static int |
OFPFW_NW_SRC_BITS |
static int |
OFPFW_NW_SRC_MASK |
static int |
OFPFW_NW_SRC_SHIFT |
static int |
OFPFW_NW_TOS |
static int |
OFPFW_TP_DST |
static int |
OFPFW_TP_SRC |
int |
priority |
int |
ruleid |
private static long |
serialVersionUID |
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 |
short |
tp_dst |
short |
tp_src |
boolean |
wildcard_dl_dst |
boolean |
wildcard_dl_src |
boolean |
wildcard_dl_type |
boolean |
wildcard_dpid |
boolean |
wildcard_in_port |
boolean |
wildcard_nw_dst |
boolean |
wildcard_nw_proto |
boolean |
wildcard_nw_src |
boolean |
wildcard_tp_dst |
boolean |
wildcard_tp_src |
Constructor and Description |
---|
FirewallRule() |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(FirewallRule rule)
Comparison method for Collections.sort method
|
int |
genID()
Generates a unique ID for the instance.
|
int |
hashCode() |
static int[] |
IPCIDRToPrefixBits(java.lang.String cidr)
Divides CIDR address into IP address and the length of mask.
|
boolean |
isSameAs(FirewallRule r)
Determines if this instance matches an existing rule instance.
|
static FirewallRule |
jsonToFirewallRule(java.lang.String fmJson)
Turns a JSON formatted Firewall Rule string into a
FirewallRule instance |
boolean |
matchesFlow(long switchDpid,
short inPort,
Ethernet packet,
WildcardsPair wildcards)
Matches this rule to a given flow - incoming packet.
|
protected boolean |
matchIPAddress(int rulePrefix,
int ruleBits,
int packetAddress)
Determines if rule's CIDR address matches IP address of the packet.
|
public static final int OFPFW_ALL
public static final int OFPFW_IN_PORT
public static final int OFPFW_DL_VLAN
public static final int OFPFW_DL_SRC
public static final int OFPFW_DL_DST
public static final int OFPFW_DL_TYPE
public static final int OFPFW_NW_PROTO
public static final int OFPFW_TP_SRC
public static final int OFPFW_TP_DST
public static final int OFPFW_NW_SRC_SHIFT
public static final int OFPFW_NW_SRC_BITS
public static final int OFPFW_NW_SRC_MASK
public static final int OFPFW_NW_SRC_ALL
public static final int OFPFW_NW_DST_SHIFT
public static final int OFPFW_NW_DST_BITS
public static final int OFPFW_NW_DST_MASK
public static final int OFPFW_NW_DST_ALL
public static final int OFPFW_DL_VLAN_PCP
public static final int OFPFW_NW_TOS
public static final short OFP_VLAN_NONE
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 static final long serialVersionUID
public int ruleid
public long dpid
public short in_port
public long dl_src
public long dl_dst
public short dl_type
public int nw_src_prefix
public int nw_src_maskbits
public int nw_dst_prefix
public int nw_dst_maskbits
public short nw_proto
public short tp_src
public short tp_dst
public boolean wildcard_dpid
public boolean wildcard_in_port
public boolean wildcard_dl_src
public boolean wildcard_dl_dst
public boolean wildcard_dl_type
public boolean wildcard_nw_src
public boolean wildcard_nw_dst
public boolean wildcard_nw_proto
public boolean wildcard_tp_src
public boolean wildcard_tp_dst
public int priority
public FirewallRule.FirewallAction action
public int genID()
public int compareTo(FirewallRule rule)
compareTo
in interface java.lang.Comparable<FirewallRule>
rule
- the rule to compare withpublic boolean isSameAs(FirewallRule r)
r
- the instance to compare withpublic boolean matchesFlow(long switchDpid, short inPort, Ethernet packet, WildcardsPair wildcards)
switchDpid
- the dpid of the connected switchinPort
- the switch port where the packet originated frompacket
- the Ethernet packet that arrives at the switchwildcards
- the pair of wildcards (allow and deny) given by Firewall
module that is used by the Firewall module's matchWithRule method
to derive wildcards for the decision to be takenprotected boolean matchIPAddress(int rulePrefix, int ruleBits, int packetAddress)
rulePrefix
- the prefix part of the CIDR addressruleBits
- the size of mask of the CIDR addresspacketAddress
- the IP address of the incoming packet to match withpublic int hashCode()
hashCode
in class java.lang.Object
public static FirewallRule jsonToFirewallRule(java.lang.String fmJson) throws java.io.IOException
FirewallRule
instancefmJson
- The JSON formatted static firewall ruleFirewallRule
instancejava.io.IOException
- If there was an error parsing the JSONpublic static int[] IPCIDRToPrefixBits(java.lang.String cidr)
cidr
- CIDR address of string