@Test public void testMatch(){ int[] cidr = new int[2]; ACLRule rule1, rule2; rule1 = new ACLRule(); cidr = IPAddressUtil.parseCIDR("10.0.0.1/32"); rule1.setNw_src_prefix(cidr[0]); rule1.setNw_src_maskbits(cidr[1]); cidr = IPAddressUtil.parseCIDR("10.0.0.2/32"); rule1.setNw_dst_prefix(cidr[0]); rule1.setNw_dst_maskbits(cidr[1]); rule1.setNw_proto(6); rule1.setTp_dst(80); rule2 = new ACLRule(); cidr = IPAddressUtil.parseCIDR("10.0.0.1/32"); rule2.setNw_src_prefix(cidr[0]); rule2.setNw_src_maskbits(cidr[1]); cidr = IPAddressUtil.parseCIDR("10.0.0.2/32"); rule2.setNw_dst_prefix(cidr[0]); rule2.setNw_dst_maskbits(cidr[1]); rule2.setNw_proto(6); rule2.setTp_dst(80); assertTrue(rule1.match(rule2)); rule1 = new ACLRule(); cidr = IPAddressUtil.parseCIDR("10.0.0.1/32"); rule1.setNw_src_prefix(cidr[0]); rule1.setNw_src_maskbits(cidr[1]); cidr = IPAddressUtil.parseCIDR("10.0.0.2/32"); rule1.setNw_dst_prefix(cidr[0]); rule1.setNw_dst_maskbits(cidr[1]); rule1.setNw_proto(6); rule2 = new ACLRule(); cidr = IPAddressUtil.parseCIDR("10.0.0.1/32"); rule2.setNw_src_prefix(cidr[0]); rule2.setNw_src_maskbits(cidr[1]); cidr = IPAddressUtil.parseCIDR("10.0.0.2/32"); rule2.setNw_dst_prefix(cidr[0]); rule2.setNw_dst_maskbits(cidr[1]); rule2.setNw_proto(11); assertFalse(rule1.match(rule2)); rule1 = new ACLRule(); cidr = IPAddressUtil.parseCIDR("10.0.0.1/32"); rule1.setNw_src_prefix(cidr[0]); rule1.setNw_src_maskbits(cidr[1]); cidr = IPAddressUtil.parseCIDR("10.0.0.2/32"); rule1.setNw_dst_prefix(cidr[0]); rule1.setNw_dst_maskbits(cidr[1]); rule1.setNw_proto(1); rule2 = new ACLRule(); cidr = IPAddressUtil.parseCIDR("10.0.0.1/8"); rule2.setNw_src_prefix(cidr[0]); rule2.setNw_src_maskbits(cidr[1]); cidr = IPAddressUtil.parseCIDR("10.0.0.2/32"); rule2.setNw_dst_prefix(cidr[0]); rule2.setNw_dst_maskbits(cidr[1]); rule2.setNw_proto(1); assertTrue(rule1.match(rule2)); rule1 = new ACLRule(); cidr = IPAddressUtil.parseCIDR("10.0.0.1/32"); rule1.setNw_src_prefix(cidr[0]); rule1.setNw_src_maskbits(cidr[1]); cidr = IPAddressUtil.parseCIDR("10.0.0.2/32"); rule1.setNw_dst_prefix(cidr[0]); rule1.setNw_dst_maskbits(cidr[1]); rule1.setNw_proto(1); rule2 = new ACLRule(); cidr = IPAddressUtil.parseCIDR("10.0.0.1/32"); rule2.setNw_src_prefix(cidr[0]); rule2.setNw_src_maskbits(cidr[1]); cidr = IPAddressUtil.parseCIDR("10.0.0.2/8"); rule2.setNw_dst_prefix(cidr[0]); rule2.setNw_dst_maskbits(cidr[1]); rule2.setNw_proto(1); assertTrue(rule1.match(rule2)); rule1 = new ACLRule(); cidr = IPAddressUtil.parseCIDR("10.0.0.1/32"); rule1.setNw_src_prefix(cidr[0]); rule1.setNw_src_maskbits(cidr[1]); cidr = IPAddressUtil.parseCIDR("10.0.0.2/32"); rule1.setNw_dst_prefix(cidr[0]); rule1.setNw_dst_maskbits(cidr[1]); rule2 = new ACLRule(); cidr = IPAddressUtil.parseCIDR("10.0.0.2/32"); rule2.setNw_dst_prefix(cidr[0]); rule2.setNw_dst_maskbits(cidr[1]); assertTrue(rule1.match(rule2)); rule1 = new ACLRule(); cidr = IPAddressUtil.parseCIDR("10.0.0.1/32"); rule1.setNw_src_prefix(cidr[0]); rule1.setNw_src_maskbits(cidr[1]); cidr = IPAddressUtil.parseCIDR("10.0.0.2/32"); rule1.setNw_dst_prefix(cidr[0]); rule1.setNw_dst_maskbits(cidr[1]); rule2 = new ACLRule(); cidr = IPAddressUtil.parseCIDR("10.0.0.1/32"); rule2.setNw_src_prefix(cidr[0]); rule2.setNw_src_maskbits(cidr[1]); assertTrue(rule1.match(rule2)); rule1 = new ACLRule(); cidr = IPAddressUtil.parseCIDR("10.0.0.1/32"); rule1.setNw_src_prefix(cidr[0]); rule1.setNw_src_maskbits(cidr[1]); cidr = IPAddressUtil.parseCIDR("10.0.0.2/32"); rule1.setNw_dst_prefix(cidr[0]); rule1.setNw_dst_maskbits(cidr[1]); rule1.setNw_proto(6); rule2 = new ACLRule(); cidr = IPAddressUtil.parseCIDR("10.0.0.1/32"); rule2.setNw_src_prefix(cidr[0]); rule2.setNw_src_maskbits(cidr[1]); cidr = IPAddressUtil.parseCIDR("10.0.0.2/32"); rule2.setNw_dst_prefix(cidr[0]); rule2.setNw_dst_maskbits(cidr[1]); assertTrue(rule1.match(rule2)); rule1 = new ACLRule(); cidr = IPAddressUtil.parseCIDR("10.0.0.1/32"); rule1.setNw_src_prefix(cidr[0]); rule1.setNw_src_maskbits(cidr[1]); cidr = IPAddressUtil.parseCIDR("10.0.0.2/32"); rule1.setNw_dst_prefix(cidr[0]); rule1.setNw_dst_maskbits(cidr[1]); rule1.setNw_proto(6); rule1.setTp_dst(80); rule2 = new ACLRule(); cidr = IPAddressUtil.parseCIDR("10.0.0.1/32"); rule2.setNw_src_prefix(cidr[0]); rule2.setNw_src_maskbits(cidr[1]); cidr = IPAddressUtil.parseCIDR("10.0.0.2/32"); rule2.setNw_dst_prefix(cidr[0]); rule2.setNw_dst_maskbits(cidr[1]); rule2.setNw_proto(6); assertTrue(rule1.match(rule2)); }
public boolean match(ACLRule r) { if ((this.tp_dst == r.tp_dst || r.tp_dst == 0) && (this.nw_proto == r.nw_proto || r.nw_proto == 0) && (isSubnet(this.getNw_src(), r.getNw_src()) == true) && (isSubnet(this.getNw_dst(), r.getNw_dst()) == true)) { return true; } return false; }
ACLRule { public boolean match(ACLRule r) { if ((this.tp_dst == r.tp_dst || r.tp_dst == 0) && (this.nw_proto == r.nw_proto || r.nw_proto == 0) && (isSubnet(this.getNw_src(), r.getNw_src()) == true) && (isSubnet(this.getNw_dst(), r.getNw_dst()) == true)) { return true; } return false; } }
ACLRule { public boolean match(ACLRule r) { if ((this.tp_dst == r.tp_dst || r.tp_dst == 0) && (this.nw_proto == r.nw_proto || r.nw_proto == 0) && (isSubnet(this.getNw_src(), r.getNw_src()) == true) && (isSubnet(this.getNw_dst(), r.getNw_dst()) == true)) { return true; } return false; } ACLRule(); }
ACLRule { public boolean match(ACLRule r) { if ((this.tp_dst == r.tp_dst || r.tp_dst == 0) && (this.nw_proto == r.nw_proto || r.nw_proto == 0) && (isSubnet(this.getNw_src(), r.getNw_src()) == true) && (isSubnet(this.getNw_dst(), r.getNw_dst()) == true)) { return true; } return false; } ACLRule(); boolean match(ACLRule r); int getId(); void setId(int id); void setNw_src(String nw_src); String getNw_src(); void setNw_dst(String nw_dst); String getNw_dst(); int getNw_src_prefix(); void setNw_src_prefix(int nw_src_prefix); int getNw_src_maskbits(); void setNw_src_maskbits(int nw_src_maskbits); int getNw_dst_prefix(); void setNw_dst_prefix(int nw_dst_prefix); int getNw_dst_maskbits(); void setNw_dst_maskbits(int nw_dst_maskbits); int getNw_proto(); void setNw_proto(int nw_proto); int getTp_dst(); void setTp_dst(int tp_dst); Action getAction(); void setAction(Action action); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }
ACLRule { public boolean match(ACLRule r) { if ((this.tp_dst == r.tp_dst || r.tp_dst == 0) && (this.nw_proto == r.nw_proto || r.nw_proto == 0) && (isSubnet(this.getNw_src(), r.getNw_src()) == true) && (isSubnet(this.getNw_dst(), r.getNw_dst()) == true)) { return true; } return false; } ACLRule(); boolean match(ACLRule r); int getId(); void setId(int id); void setNw_src(String nw_src); String getNw_src(); void setNw_dst(String nw_dst); String getNw_dst(); int getNw_src_prefix(); void setNw_src_prefix(int nw_src_prefix); int getNw_src_maskbits(); void setNw_src_maskbits(int nw_src_maskbits); int getNw_dst_prefix(); void setNw_dst_prefix(int nw_dst_prefix); int getNw_dst_maskbits(); void setNw_dst_maskbits(int nw_dst_maskbits); int getNw_proto(); void setNw_proto(int nw_proto); int getTp_dst(); void setTp_dst(int tp_dst); Action getAction(); void setAction(Action action); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj);  }