}
if (msgs == null) {
- logger.info("{} is down", this);
- reportSwitchStateChange(false);
return;
}
for (OFMessage msg : msgs) {
OFType type = msg.getType();
switch (type) {
case HELLO:
- // send feature request
- OFMessage featureRequest = factory.getMessage(OFType.FEATURES_REQUEST);
- asyncFastSend(featureRequest);
- // delete all pre-existing flows
- OFMatch match = new OFMatch().setWildcards(OFMatch.OFPFW_ALL);
- OFFlowMod flowMod = (OFFlowMod) factory.getMessage(OFType.FLOW_MOD);
- flowMod.setMatch(match).setCommand(OFFlowMod.OFPFC_DELETE).setOutPort(OFPort.OFPP_NONE)
- .setLength((short) OFFlowMod.MINIMUM_LENGTH);
- asyncFastSend(flowMod);
- this.state = SwitchState.WAIT_FEATURES_REPLY;
- startSwitchTimer();
+ sendFeaturesRequest();
break;
case ECHO_REQUEST:
OFEchoReply echoReply = (OFEchoReply) factory.getMessage(OFType.ECHO_REPLY);
// respond immediately
asyncSendNow(echoReply, msg.getXid());
+
+ // send features request if not sent yet
+ sendFeaturesRequest();
break;
case ECHO_REPLY:
this.probeSent = false;
return this.sid;
}
+ private void sendFeaturesRequest() {
+ if (!isOperational() && (this.state != SwitchState.WAIT_FEATURES_REPLY)) {
+ // send feature request
+ OFMessage featureRequest = factory.getMessage(OFType.FEATURES_REQUEST);
+ asyncFastSend(featureRequest);
+ this.state = SwitchState.WAIT_FEATURES_REPLY;
+ startSwitchTimer();
+ }
+ }
+
private void processFeaturesReply(OFFeaturesReply reply) {
if (this.state == SwitchState.WAIT_FEATURES_REPLY) {
this.sid = reply.getDatapathId();
return result;
}
}
+
+ @Override
+ public void deleteAllFlows() {
+ logger.trace("deleteAllFlows on switch {}", HexString.toHexString(this.sid));
+ OFMatch match = new OFMatch().setWildcards(OFMatch.OFPFW_ALL);
+ OFFlowMod flowMod = (OFFlowMod) factory.getMessage(OFType.FLOW_MOD);
+ flowMod.setMatch(match).setCommand(OFFlowMod.OFPFC_DELETE).setOutPort(OFPort.OFPP_NONE)
+ .setLength((short) OFFlowMod.MINIMUM_LENGTH);
+ asyncFastSend(flowMod);
+ }
}