Created
September 3, 2011 10:07
-
-
Save oshothebig/1190953 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
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { | |
if (e.getMessage() instanceof OFMessage) { | |
OFMessage in = (OFMessage)e.getMessage(); | |
log.debug("Message received: message({}), switch({})", in.getType(), ctx.getChannel().getRemoteAddress()); | |
switch (in.getType()) { | |
case HELLO: | |
ctx.getChannel().write(factory.getMessage(OFType.FEATURES_REQUEST)); | |
case ECHO_REQUEST: | |
int xid = in.getXid(); | |
OFMessage out = factory.getMessage(OFType.ECHO_REPLY); | |
out.setXid(xid); | |
// replies an ECHO_REPLY message | |
ctx.getChannel().write(out); | |
break; | |
case FEATURES_REPLY: | |
log.info("Handshake completed: switch({})", ctx.getChannel().getRemoteAddress()); | |
break; | |
case ERROR: | |
OFError error = (OFError)in; | |
log.warn("Error occurred: type({}), switch({})", error.getErrorType(), ctx.getChannel().getRemoteAddress()); | |
break; | |
default: | |
controller.invokeMessageListeners(ctx.getChannel(), in); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment