1 package org.opendaylight.controller.protocol_plugin.openflow.core.internal;
5 import org.jboss.netty.buffer.ChannelBuffer;
6 import org.jboss.netty.channel.Channel;
7 import org.jboss.netty.channel.ChannelHandlerContext;
8 import org.jboss.netty.handler.codec.frame.FrameDecoder;
9 import org.openflow.protocol.OFMessage;
10 import org.openflow.protocol.factory.BasicFactory;
11 import org.openflow.protocol.factory.OFMessageFactory;
14 * Decode an openflow message from a Channel, for use in a netty
18 public class OFMessageDecoder extends FrameDecoder {
20 OFMessageFactory factory = new BasicFactory();
23 protected Object decode(ChannelHandlerContext ctx, Channel channel,
24 ChannelBuffer buffer) throws Exception {
25 if (!channel.isConnected()) {
26 // In testing, I see decode being called AFTER decode last.
27 // This check avoids that from reading curroupted frames
31 List<OFMessage> message = factory.parseMessage(buffer);
36 protected Object decodeLast(ChannelHandlerContext ctx, Channel channel,
37 ChannelBuffer buffer) throws Exception {
38 // This is not strictly needed atthis time. It is used to detect
39 // connection reset detection from netty (for debug)