import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
public class SwitchHandler implements ISwitch {
private static final Logger logger = LoggerFactory.getLogger(SwitchHandler.class);
private static final int SWITCH_LIVENESS_TIMER = 5000;
case ECHO_REQUEST:
OFEchoReply echoReply = (OFEchoReply) factory.getMessage(OFType.ECHO_REPLY);
- // the EchoReply must have the same payload as the request
byte []payload = ((OFEchoRequest)msg).getPayload();
- echoReply.setPayload(payload);
- echoReply.setLength( (short) (echoReply.getLength() + payload.length ));
+ if (payload != null && payload.length != 0 ) {
+ // the response must have the same payload as the request
+ echoReply.setPayload(payload);
+ echoReply.setLength( (short)(echoReply.getLength() + payload.length) );
+ }
// respond immediately
asyncSendNow(echoReply, msg.getXid());