ACL implements IACLService, IFloodlightModule, IDeviceListener { @Override public void deviceIPV4AddrChanged(IDevice device) { SwitchPort[] switchPort = device.getAttachmentPoints(); IPv4Address[] ips = device.getIPv4Addresses(); String dpid = HexString.toHexString(switchPort[0].getSwitchDPID().getLong()); String ip = null; for(IPv4Address i : ips){ if(i.getInt() != 0){ ip = IPv4.fromIPv4Address(i.getInt()); break; } } logger.info("New AP added. [dpid:" + dpid + " ip:" + ip + "]"); AP ap = new AP(ip, dpid); apManager.addAP(ap); processAPAdded(ap); }  @Override List<ACLRule> getRules(); @Override boolean addRule(ACLRule rule); @Override void removeRule(int ruleid); @Override void removeAllRules(); @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override void deviceAdded(IDevice device); @Override void deviceRemoved(IDevice device); @Override void deviceMoved(IDevice device); @Override void deviceIPV4AddrChanged(IDevice device); @Override void deviceVlanChanged(IDevice device); @Override String getName(); @Override boolean isCallbackOrderingPrereq(String type, String name); @Override boolean isCallbackOrderingPostreq(String type, String name);  }
@Test public void testDeviceIPV4AddrChanged() { reset(topology); expect(topology.getL2DomainId(DatapathId.of(1L))).andReturn(DatapathId.of(1L)).anyTimes(); expect(topology.isAttachmentPointPort(DatapathId.of(1L), OFPort.of(1))).andReturn(true).anyTimes(); expect(topology.isAttachmentPointPort(DatapathId.of(2L), OFPort.of(1))).andReturn(true).anyTimes(); replay(topology); int[] cidr = new int[2]; ACLRule rule1; IResultSet resultSet; Iterator<IResultSet> it; Map<String, Object> row; deviceManager.learnEntity( Ethernet.toLong(Ethernet.toMACAddress("00:00:00:00:00:01")), null, null, 1L, 1); rule1 = new ACLRule(); rule1.setNw_src("10.0.0.0/28"); cidr = IPAddressUtil.parseCIDR("10.0.0.0/28"); rule1.setNw_src_prefix(cidr[0]); rule1.setNw_src_maskbits(cidr[1]); rule1.setNw_dst("10.0.0.254/32"); cidr = IPAddressUtil.parseCIDR("10.0.0.254/32"); rule1.setNw_dst_prefix(cidr[0]); rule1.setNw_dst_maskbits(cidr[1]); rule1.setNw_proto(6); rule1.setTp_dst(80); rule1.setAction(Action.DENY); assertEquals(acl.addRule(rule1), true); assertEquals(acl.getRules().size(), 1); resultSet = storageService.getRow( StaticFlowEntryPusher.TABLE_NAME, "ACLRule_1_00:00:00:00:00:00:00:01"); it = resultSet.iterator(); assertEquals(it.hasNext(), false); deviceManager.learnEntity( Ethernet.toLong(Ethernet.toMACAddress("00:00:00:00:00:01")), null, IPv4.toIPv4Address("10.0.0.1"), 1L, 1); resultSet = storageService.getRow( StaticFlowEntryPusher.TABLE_NAME, "ACLRule_1_00:00:00:00:00:00:00:01"); it = resultSet.iterator(); while(it.hasNext()){ row = it.next().getRow(); assertEquals(row.get("switch").toString(),"00:00:00:00:00:00:00:01"); assertEquals(row.get("priority").toString(),"30000"); assertEquals(row.get("eth_type").toString(),"2048"); assertEquals(row.get("ipv4_src").toString(),"10.0.0.0/28"); assertEquals(row.get("ipv4_dst").toString(),"10.0.0.254/32"); assertEquals(row.get("ip_proto").toString(),"6"); assertEquals(row.get("tp_dst").toString(),"80"); assertEquals(row.get("actions"), null); } }