Convert bits leaf into a set of leaves for extensibility 02/3102/1
authorRobert Varga <rovarga@cisco.com>
Tue, 26 Nov 2013 13:07:24 +0000 (14:07 +0100)
committerRobert Varga <rovarga@cisco.com>
Tue, 26 Nov 2013 14:20:00 +0000 (15:20 +0100)
Change-Id: I6cf6f940d9df5e7c8d8c0b0bec3b85661aec65fb
Signed-off-by: Robert Varga <rovarga@cisco.com>
pcep/api/src/main/yang/pcep-types.yang
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPSessionProposalFactoryImpl.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/tlv/PCEStatefulCapabilityTlvParser.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/PCEPObjectParserTest.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/PCEPTlvParserTest.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/PCEPValidatorTest.java

index 666fe46300475b5720499936ba86ebac38a5de7c..b2c8c3e963be416a3264f45644765af72f3f0872 100644 (file)
@@ -171,18 +171,21 @@ module pcep-types {
 
                container stateful {
                        uses tlv;
-                       leaf flags {
-                               type bits {
-                                       bit lsp-update-capability {
-                                               position 31;
-                                       }
-                                       bit include-db-version {
-                                               position 30;
-                                       }
-                                       bit initiation {
-                                               position 29;
-                                       }
-                               }
+
+                       leaf lsp-update-capability {
+                               type boolean;
+                               default false;
+                               // position 31;
+                       }
+                       leaf include-db-version {
+                               type boolean;
+                               default false;
+                               // position 30;
+                       }
+                       leaf initiation {
+                               type boolean;
+                               default false;
+                               // position 29;
                        }
                }
        }
index f51d9fc8a1cd3021a5032917126cb37234f4b697..006f0a8edfb6404a2525dafbbfb18789d60e5003 100644 (file)
@@ -14,7 +14,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.Tlvs;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.stateful.capability.tlv.Stateful.Flags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.stateful.capability.tlv.StatefulBuilder;
 
 public class PCEPSessionProposalFactoryImpl implements PCEPSessionProposalFactory {
@@ -39,7 +38,10 @@ public class PCEPSessionProposalFactoryImpl implements PCEPSessionProposalFactor
                final Tlvs tlvs = null;
                final TlvsBuilder builder = new TlvsBuilder();
                if (PCEPSessionProposalFactoryImpl.this.stateful) {
-                       builder.setStateful((new StatefulBuilder().setFlags(new Flags(PCEPSessionProposalFactoryImpl.this.versioned, PCEPSessionProposalFactoryImpl.this.instant, PCEPSessionProposalFactoryImpl.this.active)).build()));
+                       builder.setStateful((new StatefulBuilder().
+                                       setIncludeDbVersion(this.versioned).
+                                       setInitiation(this.instant).
+                                       setLspUpdateCapability(this.active).build()));
                }
                final OpenBuilder oBuilder = new OpenBuilder();
                oBuilder.setSessionId((short) sessionId);
index ae1bc650ae6645240ac12f75adc334292ae684c6..deaed7f71b1a92ac7b8a34c705995093ed62fcec 100644 (file)
@@ -15,7 +15,6 @@ import org.opendaylight.protocol.pcep.spi.TlvSerializer;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.stateful.capability.tlv.Stateful;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.stateful.capability.tlv.Stateful.Flags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.stateful.capability.tlv.StatefulBuilder;
 
 /**
@@ -42,7 +41,12 @@ public final class PCEStatefulCapabilityTlvParser implements TlvParser, TlvSeria
                }
 
                final BitSet flags = ByteArray.bytesToBitSet(ByteArray.subByte(buffer, 0, FLAGS_F_LENGTH));
-               return new StatefulBuilder().setFlags(new Flags(flags.get(S_FLAG_OFFSET), flags.get(I_FLAG_OFFSET), flags.get(U_FLAG_OFFSET))).build();
+
+               final StatefulBuilder sb = new StatefulBuilder();
+               sb.setIncludeDbVersion(flags.get(S_FLAG_OFFSET));
+               sb.setLspUpdateCapability(flags.get(U_FLAG_OFFSET));
+               sb.setInitiation(flags.get(I_FLAG_OFFSET));
+               return sb.build();
        }
 
        @Override
@@ -53,9 +57,9 @@ public final class PCEStatefulCapabilityTlvParser implements TlvParser, TlvSeria
                final Stateful sct = (Stateful) tlv;
 
                final BitSet flags = new BitSet(FLAGS_F_LENGTH * Byte.SIZE);
-               flags.set(I_FLAG_OFFSET, sct.getFlags().isInitiation());
-               flags.set(U_FLAG_OFFSET, sct.getFlags().isLspUpdateCapability());
-               flags.set(S_FLAG_OFFSET, sct.getFlags().isIncludeDbVersion());
+               flags.set(I_FLAG_OFFSET, sct.isInitiation());
+               flags.set(U_FLAG_OFFSET, sct.isLspUpdateCapability());
+               flags.set(S_FLAG_OFFSET, sct.isIncludeDbVersion());
 
                return ByteArray.bitSetToBytes(flags, FLAGS_F_LENGTH);
        }
index bf00caaf1ce979bd81ea6e2f267d5a01fdbe0978..857948880ccd7f7f983640e88ba8bb3ac4a7866a 100644 (file)
@@ -98,7 +98,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.RpBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.srp.object.SrpBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.stateful.capability.tlv.Stateful;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.stateful.capability.tlv.Stateful.Flags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.stateful.capability.tlv.StatefulBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.svec.object.SvecBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.symbolic.path.name.tlv.SymbolicPathName;
@@ -134,7 +133,7 @@ public class PCEPObjectParserTest {
                builder.setDeadTimer((short) 120);
                builder.setSessionId((short) 1);
 
-               final Stateful tlv1 = new StatefulBuilder().setFlags(new Flags(true, false, true)).build();
+               final Stateful tlv1 = new StatefulBuilder().setLspUpdateCapability(Boolean.TRUE).setInitiation(Boolean.FALSE).setIncludeDbVersion(Boolean.TRUE).build();
                final LspDbVersion tlv2 = new LspDbVersionBuilder().setVersion(BigInteger.valueOf(0x80L)).build();
                final byte[] predundancyBytes = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9a, (byte) 0xbc, (byte) 0xde,
                                (byte) 0xf0 };
@@ -264,7 +263,7 @@ public class PCEPObjectParserTest {
                subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.SubobjectsBuilder().setSubobjectType(
                                new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.record.route.subobjects.subobject.type.IpPrefixBuilder().setIpPrefix(
                                                new IpPrefix(Ipv6Util.prefixForBytes(ip6PrefixBytes, 22))).build()).setProtectionAvailable(false).setProtectionInUse(
-                               false).build());
+                                                               false).build());
                subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.SubobjectsBuilder().setSubobjectType(
                                new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.record.route.subobjects.subobject.type.UnnumberedBuilder().setRouterId(
                                                0x1245678L).setInterfaceId(0x9abcdef0L).build()).setProtectionAvailable(false).setProtectionInUse(false).build());
index 4a9396211f032f672e9376b7c775b5c82330b63d..80d829bb6dff1f5c2990a7cc433b1d27bfe275bd 100644 (file)
@@ -60,7 +60,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rsvp.error.spec.tlv.rsvp.error.spec.error.type.rsvp.RsvpErrorBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rsvp.error.spec.tlv.rsvp.error.spec.error.type.user.UserErrorBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.stateful.capability.tlv.Stateful;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.stateful.capability.tlv.Stateful.Flags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.stateful.capability.tlv.StatefulBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.symbolic.path.name.tlv.SymbolicPathName;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.symbolic.path.name.tlv.SymbolicPathNameBuilder;
@@ -75,39 +74,39 @@ public class PCEPTlvParserTest {
 
        private static final byte[] statefulBytes = { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x02 };
        private static final byte[] DbVersionBytes = { (byte) 0xff, (byte) 0x00, (byte) 0xff, (byte) 0xaa, (byte) 0xb2, (byte) 0xf5,
-                       (byte) 0xf2, (byte) 0xcf };
+               (byte) 0xf2, (byte) 0xcf };
        private static final byte[] noPathVectorBytes = { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0xa7 };
        private static final byte[] overloadedBytes = { (byte) 0x7f, (byte) 0xff, (byte) 0xff, (byte) 0xff };
        private static final byte[] symbolicNameBytes = { (byte) 0x4d, (byte) 0x65, (byte) 0x64, (byte) 0x20, (byte) 0x74, (byte) 0x65,
-                       (byte) 0x73, (byte) 0x74, (byte) 0x20, (byte) 0x6f, (byte) 0x66, (byte) 0x20, (byte) 0x73, (byte) 0x79, (byte) 0x6d,
-                       (byte) 0x62, (byte) 0x6f, (byte) 0x6c, (byte) 0x69, (byte) 0x63, (byte) 0x20, (byte) 0x6e, (byte) 0x61, (byte) 0x6d,
-                       (byte) 0x65 };
+               (byte) 0x73, (byte) 0x74, (byte) 0x20, (byte) 0x6f, (byte) 0x66, (byte) 0x20, (byte) 0x73, (byte) 0x79, (byte) 0x6d,
+               (byte) 0x62, (byte) 0x6f, (byte) 0x6c, (byte) 0x69, (byte) 0x63, (byte) 0x20, (byte) 0x6e, (byte) 0x61, (byte) 0x6d,
+               (byte) 0x65 };
        private static final byte[] lspUpdateErrorBytes = { (byte) 0x25, (byte) 0x68, (byte) 0x95, (byte) 0x03 };
        private static final byte[] lspIdentifiers4Bytes = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0xFF, (byte) 0xFF,
-                       (byte) 0x12, (byte) 0x34, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78 };
+               (byte) 0x12, (byte) 0x34, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78 };
        private static final byte[] lspIdentifiers6Bytes = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9A, (byte) 0xBC,
-                       (byte) 0xDE, (byte) 0xF0, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9A, (byte) 0xBC, (byte) 0xDE,
-                       (byte) 0xF0, (byte) 0x12, (byte) 0x34, (byte) 0xFF, (byte) 0xFF, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78,
-                       (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x01, (byte) 0x23, (byte) 0x45, (byte) 0x67, (byte) 0x01,
-                       (byte) 0x23, (byte) 0x45, (byte) 0x67 };
+               (byte) 0xDE, (byte) 0xF0, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9A, (byte) 0xBC, (byte) 0xDE,
+               (byte) 0xF0, (byte) 0x12, (byte) 0x34, (byte) 0xFF, (byte) 0xFF, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78,
+               (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x01, (byte) 0x23, (byte) 0x45, (byte) 0x67, (byte) 0x01,
+               (byte) 0x23, (byte) 0x45, (byte) 0x67 };
        private static final byte[] rsvpErrorBytes = { (byte) 0x06, (byte) 0x01, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78,
-                       (byte) 0x02, (byte) 0x92, (byte) 0x16, (byte) 0x02 };
+               (byte) 0x02, (byte) 0x92, (byte) 0x16, (byte) 0x02 };
        private static final byte[] rsvpError6Bytes = { (byte) 0x06, (byte) 0x02, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78,
-                       (byte) 0x9a, (byte) 0xbc, (byte) 0xde, (byte) 0xf0, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9a,
-                       (byte) 0xbc, (byte) 0xde, (byte) 0xf0, (byte) 0x02, (byte) 0xd5, (byte) 0xc5, (byte) 0xd9 };
+               (byte) 0x9a, (byte) 0xbc, (byte) 0xde, (byte) 0xf0, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9a,
+               (byte) 0xbc, (byte) 0xde, (byte) 0xf0, (byte) 0x02, (byte) 0xd5, (byte) 0xc5, (byte) 0xd9 };
        private static final byte[] userErrorBytes = { (byte) 0xc2, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x30, (byte) 0x39,
-                       (byte) 0x05, (byte) 0x09, (byte) 0x00, (byte) 0x26, (byte) 0x75, (byte) 0x73, (byte) 0x65, (byte) 0x72, (byte) 0x20,
-                       (byte) 0x64, (byte) 0x65, (byte) 0x73, (byte) 0x63 };
+               (byte) 0x05, (byte) 0x09, (byte) 0x00, (byte) 0x26, (byte) 0x75, (byte) 0x73, (byte) 0x65, (byte) 0x72, (byte) 0x20,
+               (byte) 0x64, (byte) 0x65, (byte) 0x73, (byte) 0x63 };
        private static final byte[] reqMissingBytes = { (byte) 0xF7, (byte) 0x82, (byte) 0x35, (byte) 0x17 };
        private static final byte[] orderBytes = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x00, (byte) 0x00, (byte) 0x00,
-                       (byte) 0x01 };
+               (byte) 0x01 };
        private static final byte[] ofListBytes = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78 };
        private static final byte[] predundancyBytes = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78 };
 
        @Test
        public void testStatefulTlv() throws PCEPDeserializerException {
                final PCEStatefulCapabilityTlvParser parser = new PCEStatefulCapabilityTlvParser();
-               final Stateful tlv = new StatefulBuilder().setFlags(new Flags(true, false, false)).build();
+               final Stateful tlv = new StatefulBuilder().setLspUpdateCapability(Boolean.FALSE).setInitiation(Boolean.FALSE).setIncludeDbVersion(Boolean.TRUE).build();
                assertEquals(tlv, parser.parseTlv(statefulBytes));
                assertArrayEquals(statefulBytes, parser.serializeTlv(tlv));
        }
index 8785c6d1d73e36343f10f7d55504d229228b5162..5ebe23a35c3e04dd990fc8d81a90556b3ac0c1b0 100644 (file)
@@ -122,7 +122,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.srp.object.Srp;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.srp.object.SrpBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.stateful.capability.tlv.Stateful;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.stateful.capability.tlv.Stateful.Flags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.stateful.capability.tlv.StatefulBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.svec.object.Svec;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.svec.object.SvecBuilder;
@@ -310,7 +309,7 @@ public class PCEPValidatorTest {
                b.setKeepalive((short) 30);
                b.setDeadTimer((short) 120);
                b.setSessionId((short) 1);
-               final Stateful tlv1 = new StatefulBuilder().setFlags(new Flags(true, false, true)).build();
+               final Stateful tlv1 = new StatefulBuilder().setLspUpdateCapability(Boolean.TRUE).setInitiation(Boolean.FALSE).setIncludeDbVersion(Boolean.TRUE).build();
                final LspDbVersion tlv2 = new LspDbVersionBuilder().setVersion(BigInteger.valueOf(0x80L)).build();
                b.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder().setStateful(
                                tlv1).setLspDbVersion(tlv2).build());