@Override void processOFGetConfigReply(OFChannelHandler h, OFGetConfigReply m) throws IOException { if (m.getMissSendLen() == 0xffff) { log.trace("Config Reply from switch {} confirms " + "miss length set to 0xffff", h.getSwitchInfoString()); } else { // FIXME: we can't really deal with switches that don't send // full packets. Shouldn't we drop the connection here? log.warn("Config Reply from switch {} has" + "miss length set to {}", h.getSwitchInfoString(), m.getMissSendLen()); } h.sendHandshakeDescriptionStatsRequest(); h.setState(WAIT_DESCRIPTION_STAT_REPLY); }
@Override void processOFGetConfigReply(OFGetConfigReply m) { if (m.getMissSendLen() == 0xffff) { log.trace("Config Reply from switch {} confirms " + "miss length set to 0xffff", getSwitchInfoString()); } else { // FIXME: we can't really deal with switches that don't send // full packets. Shouldn't we drop the connection here? // FIXME: count?? log.warn("Config Reply from switch {} has" + "miss length set to {}", getSwitchInfoString(), m.getMissSendLen()); } setState(new WaitDescriptionStatReplyState()); }
/** Move the channel from scratch to WAIT_DESCRIPTION_STAT_REPLY state * Builds on moveToWaitConfigReply() * adds testing for WAIT_CONFIG_REPLY state */ @Test public void moveToWaitDescriptionStatReply() throws Exception { moveToWaitConfigReply(); connection.clearMessages(); OFGetConfigReply cr = factory.buildGetConfigReply() .setMissSendLen(0xFFFF) .build(); switchHandler.processOFMessage(cr); OFMessage msg = connection.retrieveMessage(); assertEquals(OFType.STATS_REQUEST, msg.getType()); OFStatsRequest<?> sr = (OFStatsRequest<?>)msg; assertEquals(OFStatsType.DESC, sr.getStatsType()); verifyUniqueXids(msg); assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitDescriptionStatReplyState.class)); }
/** * Move the channel from scratch to WAIT_DESCRIPTION_STAT_REPLY state * Builds on moveToWaitConfigReply() * adds testing for WAIT_CONFIG_REPLY state */ @Test public void moveToWaitDescriptionStatReply() throws Exception { moveToWaitConfigReply(); resetChannel(); channel.write(capture(writeCapture)); expectLastCall().andReturn(null).atLeastOnce(); replay(channel); OFGetConfigReply cr = (OFGetConfigReply)buildOFMessage(OFType.GET_CONFIG_REPLY); sendMessageToHandlerWithControllerReset(Collections.<OFMessage>singletonList(cr)); List<OFMessage> msgs = getMessagesFromCapture(); assertEquals(1, msgs.size()); assertEquals(OFType.STATS_REQUEST, msgs.get(0).getType()); OFStatsRequest<?> sr = (OFStatsRequest<?>) msgs.get(0); assertEquals(OFStatsType.DESC, sr.getStatsType()); verifyUniqueXids(msgs); assertEquals(OFChannelHandler.ChannelState.WAIT_DESCRIPTION_STAT_REPLY, handler.getStateForTesting()); }
@Override void processOFGetConfigReply(OFChannelHandler h, OFGetConfigReply m) throws IOException { if (m.getMissSendLen() == 0xffff) { log.trace("Config Reply from switch {} confirms " + "miss length set to 0xffff", h.getSwitchInfoString()); } else { // FIXME: we can't really deal with switches that don't send // full packets. Shouldn't we drop the connection here? log.warn("Config Reply from switch {} has " + "miss length set to {}", h.getSwitchInfoString(), m.getMissSendLen()); } nextState(h); }
/** * Process an OF message received on the channel and * update state accordingly. * * The main "event" of the state machine. Process the received message, * send follow up message if required and update state if required. * * Switches on the message type and calls more specific event handlers * for each individual OF message type. If we receive a message that * is supposed to be sent from a controller to a switch we throw * a SwitchStateExeption. * * The more specific handlers can also throw SwitchStateExceptions * * @param h The OFChannelHandler that received the message * @param m The message we received. * @throws SwitchStateException * @throws IOException */ void processOFMessage(OFMessage m) { roleChanger.checkTimeout(); switch(m.getType()) { case BARRIER_REPLY: processOFBarrierReply((OFBarrierReply) m); break; case ERROR: processOFError((OFErrorMsg) m); break; case FLOW_REMOVED: processOFFlowRemoved((OFFlowRemoved) m); break; case GET_CONFIG_REPLY: processOFGetConfigReply((OFGetConfigReply) m); break; case PACKET_IN: processOFPacketIn((OFPacketIn) m); break; case PORT_STATUS: processOFPortStatus((OFPortStatus) m); break; case QUEUE_GET_CONFIG_REPLY: processOFQueueGetConfigReply((OFQueueGetConfigReply) m); break; case STATS_REPLY: processOFStatsReply((OFStatsReply) m); break; case ROLE_REPLY: processOFRoleReply((OFRoleReply) m); break; case EXPERIMENTER: processOFExperimenter((OFExperimenter) m); break; default: illegalMessageReceived(m); break; } }
@Override @LogMessageDocs({ @LogMessageDoc(level="WARN", message="Config Reply from {switch} has " + "miss length set to {length}", explanation="The controller requires that the switch " + "use a miss length of 0xffff for correct " + "function", recommendation="Use a different switch to ensure " + "correct function") }) void processOFGetConfigReply(OFGetConfigReply m) { if (m.getMissSendLen() == 0xffff) { log.trace("Config Reply from switch {} confirms " + "miss length set to 0xffff", getSwitchInfoString()); } else { // FIXME: we can't really deal with switches that don't send // full packets. Shouldn't we drop the connection here? // FIXME: count?? log.warn("Config Reply from switch {} has" + "miss length set to {}", getSwitchInfoString(), m.getMissSendLen()); } setState(new WaitDescriptionStatReplyState()); }
/** * Process an OF message received on the channel and * update state accordingly. * 处理从管道接收的OF报文并更新状态 * The main "event" of the state machine. Process the received message, * send follow up message if required and update state if required. * 处理接收报文,如果需要发送跟踪报文和更新状态 * Switches on the message type and calls more specific event handlers * for each individual OF message type. If we receive a message that * is supposed to be sent from a controller to a switch we throw * a SwitchStateExeption. * * The more specific handlers can also throw SwitchStateExceptions * * @param h The OFChannelHandler that received the message * @param m The message we received. * @throws SwitchStateException * @throws IOException */ void processOFMessage(OFMessage m) { roleChanger.checkTimeout(); switch(m.getType()) { case BARRIER_REPLY: processOFBarrierReply((OFBarrierReply) m); break; case ERROR: processOFError((OFErrorMsg) m); break; case FLOW_REMOVED: processOFFlowRemoved((OFFlowRemoved) m); break; case GET_CONFIG_REPLY: processOFGetConfigReply((OFGetConfigReply) m); break; case PACKET_IN: processOFPacketIn((OFPacketIn) m); break; case PORT_STATUS: processOFPortStatus((OFPortStatus) m); break; case QUEUE_GET_CONFIG_REPLY: processOFQueueGetConfigReply((OFQueueGetConfigReply) m); break; case STATS_REPLY: processOFStatsReply((OFStatsReply) m); break; case ROLE_REPLY: processOFRoleReply((OFRoleReply) m); break; case EXPERIMENTER: processOFExperimenter((OFExperimenter) m); break; default: illegalMessageReceived(m); break; } }
@Override @LogMessageDocs({ @LogMessageDoc(level = "WARN", message = "Config Reply from {switch} has " + "miss length set to {length}", explanation = "The controller requires that the switch " + "use a miss length of 0xffff for correct " + "function", recommendation = "Use a different switch to ensure " + "correct function") }) void processOFGetConfigReply(OFChannelHandler h, OFGetConfigReply m) throws IOException { if (m.getMissSendLen() == 0xffff) { log.trace("Config Reply from switch {} confirms " + "miss length set to 0xffff", h.getSwitchInfoString()); } else { // FIXME: we can't really deal with switches that don't send // full packets. Shouldn't we drop the connection here? log.warn("Config Reply from switch {} has" + "miss length set to {}", h.getSwitchInfoString(), m.getMissSendLen()); } h.sendHandshakeDescriptionStatsRequest(); h.setState(WAIT_DESCRIPTION_STAT_REPLY); }
@Override public void processGetConfigRequest(Channel channel, OFMessage msg) { OFGetConfigReply ofGetConfigReply = FACTORY.buildGetConfigReply() .setXid(msg.getXid()) .setMissSendLen(missSendLen) .build(); log.trace("request {}; reply {}", msg, ofGetConfigReply); channel.writeAndFlush(Collections.singletonList(ofGetConfigReply)); }
void processOFGetConfigReply(OFChannelHandler h, OFGetConfigReply m) throws IOException, SwitchStateException { // we only expect config replies in the WAIT_CONFIG_REPLY state illegalMessageReceived(h, m); }
void processOFGetConfigReply(OFGetConfigReply m) { // we only expect config replies in the WAIT_CONFIG_REPLY state // TODO: might use two different strategies depending on whether // we got a miss length of 64k or not. illegalMessageReceived(m); }