Created
September 4, 2011 14:05
-
-
Save oshothebig/1192894 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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