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
private static class OpenFlowEncoder extends OneToOneEncoder { | |
@Override | |
protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception { | |
if (msg instanceof OFMessage) { | |
OFMessage response = (OFMessage) msg; | |
// may have an bad effect on performance | |
ByteBuffer buffer = ByteBuffer.allocate(response.getLength()); | |
response.writeTo(buffer); | |
buffer.flip(); | |
return ChannelBuffers.wrappedBuffer(buffer); |
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
private static class OpenFlowDecoder extends OneToOneDecoder { | |
@Override | |
protected Object decode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception { | |
if (!(msg instanceof ChannelBuffer)) { | |
return msg; | |
} | |
ChannelBuffer channelBuffer = (ChannelBuffer)msg; | |
ByteBuffer byteBuffer = channelBuffer.toByteBuffer(); | |
List<OFMessage> messages = factory.parseMessages(byteBuffer); |
NewerOlder