[ONOS-3857] BGP update message flow specification components parsing.
Change-Id: I9b58cdf2c47cb736a8119433cbc7911d871a83d1
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpFsTcpFlags.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpFsTcpFlags.java
index fef2d3f..7af2350 100755
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpFsTcpFlags.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpFsTcpFlags.java
@@ -15,6 +15,7 @@
*/
package org.onosproject.bgpio.types;
+import java.util.LinkedList;
import java.util.Objects;
import java.util.List;
import org.jboss.netty.buffer.ChannelBuffer;
@@ -78,12 +79,28 @@
* Reads the channel buffer and returns object.
*
* @param cb channelBuffer
- * @param type address type
* @return object of flow spec TCP flags
* @throws BgpParseException while parsing BgpFsTcpFlags
*/
- public static BgpFsTcpFlags read(ChannelBuffer cb, short type) throws BgpParseException {
- return null;
+ public static BgpFsTcpFlags read(ChannelBuffer cb) throws BgpParseException {
+ List<BgpFsOperatorValue> operatorValue = new LinkedList<>();
+ byte option;
+ short tcpFlag;
+
+ do {
+ option = (byte) cb.readByte();
+ int len = (option & Constants.BGP_FLOW_SPEC_LEN_MASK) >> 4;
+ if ((1 << len) == 1) {
+ tcpFlag = cb.readByte();
+ operatorValue.add(new BgpFsOperatorValue(option, new byte[] {(byte) tcpFlag}));
+ } else {
+ tcpFlag = cb.readShort();
+ operatorValue.add(new BgpFsOperatorValue(option, new byte[] {(byte) (tcpFlag >> 8), (byte) tcpFlag}));
+ }
+
+ } while ((option & Constants.BGP_FLOW_SPEC_END_OF_LIST_MASK) == 0);
+
+ return new BgpFsTcpFlags(operatorValue);
}
@Override