@Test public void testHandleMessagesNoListeners() throws Exception { IOFSwitch sw = createMock(IOFSwitch.class); expect(sw.getId()).andReturn(0L).anyTimes(); expect(sw.getStringId()).andReturn("00:00:00:00:00:00:00").anyTimes(); replay(sw); controller.handleMessage(sw, pi, null); verify(sw); }
@LogMessageDocs({ @LogMessageDoc(level="ERROR", message="Ignoring PacketIn (Xid = {xid}) because the data" + " field is empty.", explanation="The switch sent an improperly-formatted PacketIn" + " message", recommendation=LogMessageDoc.CHECK_SWITCH), @LogMessageDoc(level="WARN", message="Unhandled OF Message: {} from {}", explanation="The switch sent a message not handled by " + "the controller") }) protected void handleMessage(IOFSwitch sw, OFMessage m, FloodlightContext bContext) throws IOException { Ethernet eth = null; if (this.notifiedRole == Role.SLAVE) { counters.dispatchMessageWhileSlave.updateCounterNoFlush(); return; } counters.dispatchMessage.updateCounterNoFlush(); switch (m.getType()) { case PACKET_IN: OFPacketIn pi = (OFPacketIn)m; if (pi.getPacketData().length <= 0) { log.error("Ignoring PacketIn (Xid = " + pi.getXid() + ") because the data field is empty."); return; } if (Controller.ALWAYS_DECODE_ETH) { eth = new Ethernet(); eth.deserialize(pi.getPacketData(), 0, pi.getPacketData().length); counterStore.updatePacketInCountersLocal(sw, m, eth); } default: List<IOFMessageListener> listeners = null; if (messageListeners.containsKey(m.getType())) { listeners = messageListeners.get(m.getType()). getOrderedListeners(); } FloodlightContext bc = null; if (listeners != null) { if (bContext == null) { bc = flcontext_alloc(); } else { bc = bContext; } if (eth != null) { IFloodlightProviderService.bcStore.put(bc, IFloodlightProviderService.CONTEXT_PI_PAYLOAD, eth); } pktinProcTime.recordStartTimePktIn(); Command cmd; for (IOFMessageListener listener : listeners) { pktinProcTime.recordStartTimeComp(listener); cmd = listener.receive(sw, m, bc); pktinProcTime.recordEndTimeComp(listener); if (Command.STOP.equals(cmd)) { break; } } pktinProcTime.recordEndTimePktIn(sw, m, bc); } else { if (m.getType() != OFType.BARRIER_REPLY) log.warn("Unhandled OF Message: {} from {}", m, sw); else log.debug("Received a Barrier Reply, no listeners for it"); } if ((bContext == null) && (bc != null)) flcontext_free(bc); } }
Controller implements IFloodlightProviderService,
            IStorageSourceListener, IInfoProvider { @LogMessageDocs({ @LogMessageDoc(level="ERROR", message="Ignoring PacketIn (Xid = {xid}) because the data" + " field is empty.", explanation="The switch sent an improperly-formatted PacketIn" + " message", recommendation=LogMessageDoc.CHECK_SWITCH), @LogMessageDoc(level="WARN", message="Unhandled OF Message: {} from {}", explanation="The switch sent a message not handled by " + "the controller") }) protected void handleMessage(IOFSwitch sw, OFMessage m, FloodlightContext bContext) throws IOException { Ethernet eth = null; if (this.notifiedRole == Role.SLAVE) { counters.dispatchMessageWhileSlave.updateCounterNoFlush(); return; } counters.dispatchMessage.updateCounterNoFlush(); switch (m.getType()) { case PACKET_IN: OFPacketIn pi = (OFPacketIn)m; if (pi.getPacketData().length <= 0) { log.error("Ignoring PacketIn (Xid = " + pi.getXid() + ") because the data field is empty."); return; } if (Controller.ALWAYS_DECODE_ETH) { eth = new Ethernet(); eth.deserialize(pi.getPacketData(), 0, pi.getPacketData().length); counterStore.updatePacketInCountersLocal(sw, m, eth); } default: List<IOFMessageListener> listeners = null; if (messageListeners.containsKey(m.getType())) { listeners = messageListeners.get(m.getType()). getOrderedListeners(); } FloodlightContext bc = null; if (listeners != null) { if (bContext == null) { bc = flcontext_alloc(); } else { bc = bContext; } if (eth != null) { IFloodlightProviderService.bcStore.put(bc, IFloodlightProviderService.CONTEXT_PI_PAYLOAD, eth); } pktinProcTime.recordStartTimePktIn(); Command cmd; for (IOFMessageListener listener : listeners) { pktinProcTime.recordStartTimeComp(listener); cmd = listener.receive(sw, m, bc); pktinProcTime.recordEndTimeComp(listener); if (Command.STOP.equals(cmd)) { break; } } pktinProcTime.recordEndTimePktIn(sw, m, bc); } else { if (m.getType() != OFType.BARRIER_REPLY) log.warn("Unhandled OF Message: {} from {}", m, sw); else log.debug("Received a Barrier Reply, no listeners for it"); } if ((bContext == null) && (bc != null)) flcontext_free(bc); } } }
Controller implements IFloodlightProviderService,
            IStorageSourceListener, IInfoProvider { @LogMessageDocs({ @LogMessageDoc(level="ERROR", message="Ignoring PacketIn (Xid = {xid}) because the data" + " field is empty.", explanation="The switch sent an improperly-formatted PacketIn" + " message", recommendation=LogMessageDoc.CHECK_SWITCH), @LogMessageDoc(level="WARN", message="Unhandled OF Message: {} from {}", explanation="The switch sent a message not handled by " + "the controller") }) protected void handleMessage(IOFSwitch sw, OFMessage m, FloodlightContext bContext) throws IOException { Ethernet eth = null; if (this.notifiedRole == Role.SLAVE) { counters.dispatchMessageWhileSlave.updateCounterNoFlush(); return; } counters.dispatchMessage.updateCounterNoFlush(); switch (m.getType()) { case PACKET_IN: OFPacketIn pi = (OFPacketIn)m; if (pi.getPacketData().length <= 0) { log.error("Ignoring PacketIn (Xid = " + pi.getXid() + ") because the data field is empty."); return; } if (Controller.ALWAYS_DECODE_ETH) { eth = new Ethernet(); eth.deserialize(pi.getPacketData(), 0, pi.getPacketData().length); counterStore.updatePacketInCountersLocal(sw, m, eth); } default: List<IOFMessageListener> listeners = null; if (messageListeners.containsKey(m.getType())) { listeners = messageListeners.get(m.getType()). getOrderedListeners(); } FloodlightContext bc = null; if (listeners != null) { if (bContext == null) { bc = flcontext_alloc(); } else { bc = bContext; } if (eth != null) { IFloodlightProviderService.bcStore.put(bc, IFloodlightProviderService.CONTEXT_PI_PAYLOAD, eth); } pktinProcTime.recordStartTimePktIn(); Command cmd; for (IOFMessageListener listener : listeners) { pktinProcTime.recordStartTimeComp(listener); cmd = listener.receive(sw, m, bc); pktinProcTime.recordEndTimeComp(listener); if (Command.STOP.equals(cmd)) { break; } } pktinProcTime.recordEndTimePktIn(sw, m, bc); } else { if (m.getType() != OFType.BARRIER_REPLY) log.warn("Unhandled OF Message: {} from {}", m, sw); else log.debug("Received a Barrier Reply, no listeners for it"); } if ((bContext == null) && (bc != null)) flcontext_free(bc); } }  }
Controller implements IFloodlightProviderService,
            IStorageSourceListener, IInfoProvider { @LogMessageDocs({ @LogMessageDoc(level="ERROR", message="Ignoring PacketIn (Xid = {xid}) because the data" + " field is empty.", explanation="The switch sent an improperly-formatted PacketIn" + " message", recommendation=LogMessageDoc.CHECK_SWITCH), @LogMessageDoc(level="WARN", message="Unhandled OF Message: {} from {}", explanation="The switch sent a message not handled by " + "the controller") }) protected void handleMessage(IOFSwitch sw, OFMessage m, FloodlightContext bContext) throws IOException { Ethernet eth = null; if (this.notifiedRole == Role.SLAVE) { counters.dispatchMessageWhileSlave.updateCounterNoFlush(); return; } counters.dispatchMessage.updateCounterNoFlush(); switch (m.getType()) { case PACKET_IN: OFPacketIn pi = (OFPacketIn)m; if (pi.getPacketData().length <= 0) { log.error("Ignoring PacketIn (Xid = " + pi.getXid() + ") because the data field is empty."); return; } if (Controller.ALWAYS_DECODE_ETH) { eth = new Ethernet(); eth.deserialize(pi.getPacketData(), 0, pi.getPacketData().length); counterStore.updatePacketInCountersLocal(sw, m, eth); } default: List<IOFMessageListener> listeners = null; if (messageListeners.containsKey(m.getType())) { listeners = messageListeners.get(m.getType()). getOrderedListeners(); } FloodlightContext bc = null; if (listeners != null) { if (bContext == null) { bc = flcontext_alloc(); } else { bc = bContext; } if (eth != null) { IFloodlightProviderService.bcStore.put(bc, IFloodlightProviderService.CONTEXT_PI_PAYLOAD, eth); } pktinProcTime.recordStartTimePktIn(); Command cmd; for (IOFMessageListener listener : listeners) { pktinProcTime.recordStartTimeComp(listener); cmd = listener.receive(sw, m, bc); pktinProcTime.recordEndTimeComp(listener); if (Command.STOP.equals(cmd)) { break; } } pktinProcTime.recordEndTimePktIn(sw, m, bc); } else { if (m.getType() != OFType.BARRIER_REPLY) log.warn("Unhandled OF Message: {} from {}", m, sw); else log.debug("Received a Barrier Reply, no listeners for it"); } if ((bContext == null) && (bc != null)) flcontext_free(bc); } }  @Override Set<String> getUplinkPortPrefixSet(); void setUplinkPortPrefixSet(Set<String> prefixSet); void setDebugEvent(IDebugEventService debugEvent); @Override Role getRole(); @Override RoleInfo getRoleInfo(); @Override void setRole(Role role, String roleChangeDescription); @Override Map<Long,IOFSwitch> getAllSwitchMap(); @Override Set<Long> getAllSwitchDpids(); @Override IOFSwitch getSwitch(long dpid); @Override void addOFSwitchListener(IOFSwitchListener listener); @Override void removeOFSwitchListener(IOFSwitchListener listener); @Override synchronized void addOFMessageListener(OFType type,
                                                  IOFMessageListener listener); @Override synchronized void removeOFMessageListener(OFType type,
                                                     IOFMessageListener listener); void removeOFMessageListeners(OFType type); @Override Map<OFType, List<IOFMessageListener>> getListeners(); @Override @LogMessageDocs({ @LogMessageDoc(level="ERROR", message="Error reinjecting OFMessage on switch {switch}", explanation="An I/O error occured while attempting to " + "process an OpenFlow message", recommendation=LogMessageDoc.CHECK_SWITCH) }) boolean injectOfMessage(IOFSwitch sw, OFMessage msg,
                                   FloodlightContext bc); @Override @LogMessageDoc(message="Calling System.exit", explanation="The controller is terminating") synchronized void terminate(); @Override boolean injectOfMessage(IOFSwitch sw, OFMessage msg); @Override void handleOutgoingMessage(IOFSwitch sw, OFMessage m,
                                      FloodlightContext bc); @Override BasicFactory getOFMessageFactory(); @Override @LogMessageDocs({ @LogMessageDoc(message="Listening for switch connections on {address}", explanation="The controller is ready and listening for new" + " switch connections"), @LogMessageDoc(message="Storage exception in controller " + "updates loop; terminating process", explanation=ERROR_DATABASE, recommendation=LogMessageDoc.CHECK_CONTROLLER), @LogMessageDoc(level="ERROR", message="Exception in controller updates loop", explanation="Failed to dispatch controller event", recommendation=LogMessageDoc.GENERIC_ACTION) }) void run(); void init(Map<String, String> configParams); @LogMessageDoc(message="Waiting for storage source", explanation="The system database is not yet ready", recommendation="If this message persists, this indicates " + "that the system database has failed to start. " + LogMessageDoc.CHECK_CONTROLLER) void startupComponents(); @Override void addInfoProvider(String type, IInfoProvider provider); @Override void removeInfoProvider(String type, IInfoProvider provider); @Override Map<String, Object> getControllerInfo(String type); @Override void addHAListener(IHAListener listener); @Override void removeHAListener(IHAListener listener); @Override void addReadyForReconcileListener(IReadyForReconcileListener l); @Override Map<String, String> getControllerNodeIPs(); @LogMessageDoc(level="WARN", message=FLOW_PRIORITY_CHANGED_AFTER_STARTUP, explanation="A user has changed the priority with which access " + "and core flows are installed after controller startup. " + "Changing this setting will only take affect after a " + "controller restart", recommendation="Restart controller") @Override void rowsModified(String tableName, Set<Object> rowKeys); @Override void rowsDeleted(String tableName, Set<Object> rowKeys); @Override long getSystemStartTime(); @Override void setAlwaysClearFlowsOnSwActivate(boolean value); @Override Map<String, Long> getMemory(); @Override Long getUptime(); @Override void addOFSwitchDriver(String manufacturerDescriptionPrefix,
                                  IOFSwitchDriver driver); @Override void addSwitchEvent(long switchDPID, String reason, boolean flushNow); @Override Map<String, Object> getInfo(String type); }
Controller implements IFloodlightProviderService,
            IStorageSourceListener, IInfoProvider { @LogMessageDocs({ @LogMessageDoc(level="ERROR", message="Ignoring PacketIn (Xid = {xid}) because the data" + " field is empty.", explanation="The switch sent an improperly-formatted PacketIn" + " message", recommendation=LogMessageDoc.CHECK_SWITCH), @LogMessageDoc(level="WARN", message="Unhandled OF Message: {} from {}", explanation="The switch sent a message not handled by " + "the controller") }) protected void handleMessage(IOFSwitch sw, OFMessage m, FloodlightContext bContext) throws IOException { Ethernet eth = null; if (this.notifiedRole == Role.SLAVE) { counters.dispatchMessageWhileSlave.updateCounterNoFlush(); return; } counters.dispatchMessage.updateCounterNoFlush(); switch (m.getType()) { case PACKET_IN: OFPacketIn pi = (OFPacketIn)m; if (pi.getPacketData().length <= 0) { log.error("Ignoring PacketIn (Xid = " + pi.getXid() + ") because the data field is empty."); return; } if (Controller.ALWAYS_DECODE_ETH) { eth = new Ethernet(); eth.deserialize(pi.getPacketData(), 0, pi.getPacketData().length); counterStore.updatePacketInCountersLocal(sw, m, eth); } default: List<IOFMessageListener> listeners = null; if (messageListeners.containsKey(m.getType())) { listeners = messageListeners.get(m.getType()). getOrderedListeners(); } FloodlightContext bc = null; if (listeners != null) { if (bContext == null) { bc = flcontext_alloc(); } else { bc = bContext; } if (eth != null) { IFloodlightProviderService.bcStore.put(bc, IFloodlightProviderService.CONTEXT_PI_PAYLOAD, eth); } pktinProcTime.recordStartTimePktIn(); Command cmd; for (IOFMessageListener listener : listeners) { pktinProcTime.recordStartTimeComp(listener); cmd = listener.receive(sw, m, bc); pktinProcTime.recordEndTimeComp(listener); if (Command.STOP.equals(cmd)) { break; } } pktinProcTime.recordEndTimePktIn(sw, m, bc); } else { if (m.getType() != OFType.BARRIER_REPLY) log.warn("Unhandled OF Message: {} from {}", m, sw); else log.debug("Received a Barrier Reply, no listeners for it"); } if ((bContext == null) && (bc != null)) flcontext_free(bc); } }  @Override Set<String> getUplinkPortPrefixSet(); void setUplinkPortPrefixSet(Set<String> prefixSet); void setDebugEvent(IDebugEventService debugEvent); @Override Role getRole(); @Override RoleInfo getRoleInfo(); @Override void setRole(Role role, String roleChangeDescription); @Override Map<Long,IOFSwitch> getAllSwitchMap(); @Override Set<Long> getAllSwitchDpids(); @Override IOFSwitch getSwitch(long dpid); @Override void addOFSwitchListener(IOFSwitchListener listener); @Override void removeOFSwitchListener(IOFSwitchListener listener); @Override synchronized void addOFMessageListener(OFType type,
                                                  IOFMessageListener listener); @Override synchronized void removeOFMessageListener(OFType type,
                                                     IOFMessageListener listener); void removeOFMessageListeners(OFType type); @Override Map<OFType, List<IOFMessageListener>> getListeners(); @Override @LogMessageDocs({ @LogMessageDoc(level="ERROR", message="Error reinjecting OFMessage on switch {switch}", explanation="An I/O error occured while attempting to " + "process an OpenFlow message", recommendation=LogMessageDoc.CHECK_SWITCH) }) boolean injectOfMessage(IOFSwitch sw, OFMessage msg,
                                   FloodlightContext bc); @Override @LogMessageDoc(message="Calling System.exit", explanation="The controller is terminating") synchronized void terminate(); @Override boolean injectOfMessage(IOFSwitch sw, OFMessage msg); @Override void handleOutgoingMessage(IOFSwitch sw, OFMessage m,
                                      FloodlightContext bc); @Override BasicFactory getOFMessageFactory(); @Override @LogMessageDocs({ @LogMessageDoc(message="Listening for switch connections on {address}", explanation="The controller is ready and listening for new" + " switch connections"), @LogMessageDoc(message="Storage exception in controller " + "updates loop; terminating process", explanation=ERROR_DATABASE, recommendation=LogMessageDoc.CHECK_CONTROLLER), @LogMessageDoc(level="ERROR", message="Exception in controller updates loop", explanation="Failed to dispatch controller event", recommendation=LogMessageDoc.GENERIC_ACTION) }) void run(); void init(Map<String, String> configParams); @LogMessageDoc(message="Waiting for storage source", explanation="The system database is not yet ready", recommendation="If this message persists, this indicates " + "that the system database has failed to start. " + LogMessageDoc.CHECK_CONTROLLER) void startupComponents(); @Override void addInfoProvider(String type, IInfoProvider provider); @Override void removeInfoProvider(String type, IInfoProvider provider); @Override Map<String, Object> getControllerInfo(String type); @Override void addHAListener(IHAListener listener); @Override void removeHAListener(IHAListener listener); @Override void addReadyForReconcileListener(IReadyForReconcileListener l); @Override Map<String, String> getControllerNodeIPs(); @LogMessageDoc(level="WARN", message=FLOW_PRIORITY_CHANGED_AFTER_STARTUP, explanation="A user has changed the priority with which access " + "and core flows are installed after controller startup. " + "Changing this setting will only take affect after a " + "controller restart", recommendation="Restart controller") @Override void rowsModified(String tableName, Set<Object> rowKeys); @Override void rowsDeleted(String tableName, Set<Object> rowKeys); @Override long getSystemStartTime(); @Override void setAlwaysClearFlowsOnSwActivate(boolean value); @Override Map<String, Long> getMemory(); @Override Long getUptime(); @Override void addOFSwitchDriver(String manufacturerDescriptionPrefix,
                                  IOFSwitchDriver driver); @Override void addSwitchEvent(long switchDPID, String reason, boolean flushNow); @Override Map<String, Object> getInfo(String type); static final int BATCH_MAX_SIZE; }