BUG 4137: Fix XRO SRLG Parser 66/25366/1
authorClaudio D. Gasparini <cgaspari@cisco.com>
Mon, 17 Aug 2015 14:29:43 +0000 (16:29 +0200)
committerClaudio D. Gasparini <cgaspari@cisco.com>
Mon, 17 Aug 2015 14:31:20 +0000 (16:31 +0200)
Change-Id: I3944b01c179c6b6c46aab1e140c50b41e67ef5fb
Signed-off-by: Claudio D. Gasparini <cgaspari@cisco.com>
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/XROSRLGSubobjectParser.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/PCEPXROSubobjectParserTest.java

index 9cbd321e03f9d6ffb4a92c3f3c4b1f48bcd32516..2059ca63435546b5219037a288db87b3c51e5454 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.protocol.pcep.impl.subobject;
 
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
-
 import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
@@ -19,7 +18,7 @@ import org.opendaylight.protocol.pcep.spi.XROSubobjectSerializer;
 import org.opendaylight.protocol.pcep.spi.XROSubobjectUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.xro.Subobject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.xro.SubobjectBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.ExcludeRouteSubobjects.Attribute;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.ExcludeRouteSubobjects;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.SrlgId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.SrlgSubobject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.subobject.type.SrlgCase;
@@ -33,7 +32,7 @@ public class XROSRLGSubobjectParser implements XROSubobjectParser, XROSubobjectS
 
     public static final int TYPE = 34;
 
-    private static final int CONTENT_LENGTH = 5;
+    private static final int CONTENT_LENGTH = 6;
 
     @Override
     public Subobject parseSubobject(final ByteBuf buffer, final boolean mandatory) throws PCEPDeserializerException {
@@ -44,8 +43,10 @@ public class XROSRLGSubobjectParser implements XROSubobjectParser, XROSubobjectS
         }
         final SubobjectBuilder builder = new SubobjectBuilder();
         builder.setMandatory(mandatory);
-        builder.setAttribute(Attribute.Srlg);
+
         builder.setSubobjectType(new SrlgCaseBuilder().setSrlg(new SrlgBuilder().setSrlgId(new SrlgId(buffer.readUnsignedInt())).build()).build());
+        buffer.readByte();
+        builder.setAttribute(ExcludeRouteSubobjects.Attribute.forValue(buffer.readUnsignedByte()));
         return builder.build();
     }
 
@@ -57,6 +58,7 @@ public class XROSRLGSubobjectParser implements XROSubobjectParser, XROSubobjectS
         Preconditions.checkArgument(specObj.getSrlgId() != null, "SrlgId is mandatory.");
         writeUnsignedInt(specObj.getSrlgId().getValue(), body);
         Preconditions.checkArgument(subobject.getAttribute() != null, "Attribute is mandatory.");
+        writeUnsignedByte(null, body);
         writeUnsignedByte((short) subobject.getAttribute().getIntValue(), body);
         XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), body, buffer);
     }
index a69e84ac8e7b58d41d1046470a0565e25adc5487..aee4cf8cbc155c8862524398d1a9973f6ba653cc 100644 (file)
@@ -50,7 +50,7 @@ public class PCEPXROSubobjectParserTest {
     private static final byte[] ip6PrefixBytes = { (byte) 0x82, (byte) 0x14, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
         (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
         (byte) 0xFF, (byte) 0xFF, (byte) 0x16, (byte) 0x01 };
-    private static final byte[] srlgBytes = { (byte) 0xa2, (byte) 0x07, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x02 };
+    private static final byte[] srlgBytes = { (byte) 0xa2, (byte) 0x08, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x00, (byte) 0x02 };
     private static final byte[] unnumberedBytes = { (byte) 0x84, (byte) 0x0c, (byte) 0x00, (byte) 0x01, (byte) 0x12, (byte) 0x34,
         (byte) 0x50, (byte) 0x00, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
     private static final byte[] asNumberBytes = { (byte) 0xa0, (byte) 0x04, (byte) 0x00, (byte) 0x64 };