Shashikanth VH
Committed by Gerrit Code Review

[ONOS-2596] BGP message decode

Change-Id: I8b458b33bffd552347e379f28084fc7449af0bcf
...@@ -24,6 +24,9 @@ import org.jboss.netty.channel.ChannelHandlerContext; ...@@ -24,6 +24,9 @@ import org.jboss.netty.channel.ChannelHandlerContext;
24 import org.jboss.netty.handler.codec.frame.FrameDecoder; 24 import org.jboss.netty.handler.codec.frame.FrameDecoder;
25 import org.onosproject.bgpio.protocol.BGPMessage; 25 import org.onosproject.bgpio.protocol.BGPMessage;
26 import org.onlab.util.HexDump; 26 import org.onlab.util.HexDump;
27 +import org.onosproject.bgpio.protocol.BGPFactories;
28 +import org.onosproject.bgpio.protocol.BGPMessageReader;
29 +import org.onosproject.bgpio.types.BGPHeader;
27 import org.slf4j.Logger; 30 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory; 31 import org.slf4j.LoggerFactory;
29 32
...@@ -36,9 +39,6 @@ public class BGPMessageDecoder extends FrameDecoder { ...@@ -36,9 +39,6 @@ public class BGPMessageDecoder extends FrameDecoder {
36 39
37 @Override 40 @Override
38 protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception { 41 protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception {
39 -
40 - List<BGPMessage> msgList = new LinkedList<BGPMessage>();
41 -
42 log.debug("MESSAGE IS RECEIVED."); 42 log.debug("MESSAGE IS RECEIVED.");
43 if (!channel.isConnected()) { 43 if (!channel.isConnected()) {
44 log.info("Channel is not connected."); 44 log.info("Channel is not connected.");
...@@ -47,7 +47,14 @@ public class BGPMessageDecoder extends FrameDecoder { ...@@ -47,7 +47,14 @@ public class BGPMessageDecoder extends FrameDecoder {
47 47
48 HexDump.dump(buffer); 48 HexDump.dump(buffer);
49 49
50 - // TODO: decode bgp messages 50 + BGPMessageReader<BGPMessage> reader = BGPFactories.getGenericReader();
51 + List<BGPMessage> msgList = new LinkedList<BGPMessage>();
52 +
53 + while (buffer.readableBytes() > 0) {
54 + BGPHeader bgpHeader = new BGPHeader();
55 + BGPMessage message = reader.readFrom(buffer, bgpHeader);
56 + msgList.add(message);
57 + }
51 return msgList; 58 return msgList;
52 } 59 }
53 } 60 }
...\ No newline at end of file ...\ No newline at end of file
......