Skip to content

Instantly share code, notes, and snippets.

@oshothebig
Created September 4, 2011 14:05
Show Gist options
  • Save oshothebig/1192894 to your computer and use it in GitHub Desktop.
Save oshothebig/1192894 to your computer and use it in GitHub Desktop.
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
OFMessage in = (OFMessage) e.getMessage();
OFMessage out;
switch (in.getType()) {
case HELLO:
break;
case ECHO_REQUEST:
out = fakeSwitch.echoReplyData((OFEchoRequest)in);
ctx.getChannel().write(out);
break;
case FEATURES_REQUEST:
out = fakeSwitch.featureReplyData((OFFeaturesRequest)in);
ctx.getChannel().write(out);
break;
case GET_CONFIG_REQUEST:
out = fakeSwitch.getConfigReplyData((OFGetConfigRequest)in);
ctx.getChannel().write(out);
break;
case VENDOR:
out = fakeSwitch.vendorReplyData((OFVendor)in);
ctx.getChannel().write(out);
case PACKET_OUT:
case FLOW_MOD:
long currentTime = System.nanoTime();
if (currentTime > benchmarkEndTime) {
break;
}
fakeSwitch.receiveMessages();
out = fakeSwitch.packetInData();
ChannelFuture future = ctx.getChannel().write(out);
future.addListener(new ChannelFutureListener() {
public void operationComplete(ChannelFuture channelFuture) throws Exception {
fakeSwitch.sendingPacketInCompleted();
}
});
break;
default:
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment