Bug-2225: Move Path Setup Type TLV to base PCEP 15/13715/4
authorMilos Fabian <milfabia@cisco.com>
Thu, 4 Dec 2014 10:14:04 +0000 (11:14 +0100)
committerDana Kutenicsova <dkutenic@cisco.com>
Mon, 12 Jan 2015 13:37:34 +0000 (13:37 +0000)
-moved PST TLV yang model to pcep-types.yang
-added to RP Object TLV container
-added to SRP Object TLV container in stateful07
-moved/updated parsers/serializers according to changes in model
-segment routnig extends PST TLV parser/serializer - can handle PST=1
-added PST TLV as input argument in addLsp and updateLsp
-addLsp - optional for RSVP-TE, resp. PST TLV is omitted in message when PST=0; must be present for SR
-updateLsp - if present, use PST TLV defined in input argument; otherwise use stored one.
-LSP can be migrated from RSVP-TE to SR-TE and vice-versa -> PST TLV must be explicitly included in input args.
-removeLsp - stored PST TLV is used
-PST TLV is exposed in pcep-topology - if present in report message

-motivation:
-get rid of ugly augmentations in segment-routing
-get rid of hacking (adding PST TLV) in PCEP SR messages serializer

-reference: https://tools.ietf.org/html/draft-sivabalan-pce-lsp-setup-type-02

Change-Id: Id6e099fe5bb55e7436c7e89df4821a547ed065b8
Signed-off-by: Milos Fabian <milfabia@cisco.com>
28 files changed:
pcep/api/src/main/yang/pcep-types.yang
pcep/ietf-stateful07/src/main/java/org/opendaylight/protocol/pcep/ietf/stateful07/Stateful07SrpObjectParser.java
pcep/ietf-stateful07/src/main/yang/odl-pcep-ietf-stateful07.yang
pcep/ietf-stateful07/src/test/java/org/opendaylight/protocol/pcep/ietf/PCEPObjectParserTest.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/Activator.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPRequestParameterObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/tlv/PathSetupTypeTlvParser.java [moved from pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/lsp/setup/type01/PathSetupTypeTlvParser.java with 60% similarity]
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/segment-routing/src/main/java/org/opendaylight/protocol/pcep/lsp/setup/type01/CInitiated00SrpObjectWithPstTlvParser.java [deleted file]
pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/lsp/setup/type01/PcepRpObjectWithPstTlvParser.java [deleted file]
pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/segment/routing02/SegmentRoutingActivator.java
pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/segment/routing02/SrEroUtil.java
pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/segment/routing02/SrPathSetupTypeTlvParser.java [new file with mode: 0644]
pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/segment/routing02/SrPcInitiateMessageParser.java
pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/segment/routing02/SrPcRepMessageParser.java
pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/segment/routing02/SrPcRptMessageParser.java
pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/segment/routing02/SrPcUpdMessageParser.java
pcep/segment-routing/src/main/yang/odl-pcep-lsp-setup-type01.yang [deleted file]
pcep/segment-routing/src/main/yang/odl-pcep-segment-routing02.yang
pcep/segment-routing/src/test/java/org/opendaylight/protocol/pcep/lsp/setup/type01/PcepObjectParserTest.java [deleted file]
pcep/segment-routing/src/test/java/org/opendaylight/protocol/pcep/lsp/setup/type01/PcepTlvParserTest.java [deleted file]
pcep/segment-routing/src/test/java/org/opendaylight/protocol/pcep/segment/routing02/SrEroUtilTest.java
pcep/segment-routing/src/test/java/org/opendaylight/protocol/pcep/segment/routing02/SrMessageParserTest.java
pcep/segment-routing/src/test/java/org/opendaylight/protocol/pcep/segment/routing02/SrTlvParserTest.java
pcep/segment-routing/src/test/java/org/opendaylight/protocol/pcep/segment/routing02/TopologyProviderTest.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/PCEPErrors.java
pcep/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/Stateful07TopologySessionListener.java

index 9e2e0ef85acb20220374e480f8fa67c7faef42c2..ebaed88008545353d40f868a28983cec39a4e32a 100644 (file)
@@ -184,6 +184,20 @@ module pcep-types {
         }
     }
 
+    grouping path-setup-type-tlv {
+        description "PATH-SETUP-TYPE TLV";
+        reference "https://tools.ietf.org/html/draft-sivabalan-pce-lsp-setup-type-02#section-3";
+
+        container path-setup-type {
+            uses tlv;
+            leaf pst {
+                description "PST=0: Path is setup via RSVP-TE signaling protocol(default).";
+                type uint8;
+                default 0;
+            }
+        }
+    }
+
     // Objects
     grouping object-header {
         description "Common Object Header";
@@ -267,6 +281,7 @@ module pcep-types {
             container "tlvs" {
                 uses order-tlv;
                 uses vendor-information-tlvs;
+                uses path-setup-type-tlv;
             }
 
             leaf priority {
index b2a313438adbbd16a0b9df01d748bfe75422922d..263c0fb0c6f60bf08a19268692e6680470637c91 100644 (file)
@@ -27,6 +27,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.iet
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
 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.path.setup.type.tlv.PathSetupType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.tlvs.VendorInformationTlv;
 
 /**
@@ -73,6 +74,9 @@ public class Stateful07SrpObjectParser extends AbstractObjectWithTlvsParser<Tlvs
         if (tlv instanceof SymbolicPathName) {
             builder.setSymbolicPathName((SymbolicPathName) tlv);
         }
+        if (tlv instanceof PathSetupType) {
+            builder.setPathSetupType((PathSetupType) tlv);
+        }
     }
 
     @Override
@@ -91,9 +95,13 @@ public class Stateful07SrpObjectParser extends AbstractObjectWithTlvsParser<Tlvs
     public void serializeTlvs(final Tlvs tlvs, final ByteBuf body) {
         if (tlvs == null) {
             return;
-        } else if (tlvs.getSymbolicPathName() != null) {
+        }
+        if (tlvs.getSymbolicPathName() != null) {
             serializeTlv(tlvs.getSymbolicPathName(), body);
         }
+        if (tlvs.getPathSetupType() != null) {
+            serializeTlv(tlvs.getPathSetupType(), body);
+        }
     }
 
     @Override
index f724e83da35ed899afbb536d465ea2cc6964108c..60234ea0a51e60c4a9c72558824dd309fb073c62 100644 (file)
@@ -239,6 +239,8 @@ module odl-pcep-ietf-stateful07 {
                 uses symbolic-path-name-tlv;
 
                 uses pcep:vendor-information-tlvs;
+
+                uses pcep:path-setup-type-tlv;
             }
 
             leaf operation-id {
@@ -331,6 +333,7 @@ module odl-pcep-ietf-stateful07 {
 
     augment "/nt:network-topology/nt:topology/nt:node/topo:path-computation-client/topo:reported-lsp/topo:path" {
         uses lsp-object;
+        uses pcep:path-setup-type-tlv;
     }
 
     augment "/nt:network-topology/nt:topology/nt:node/topo:path-computation-client/topo:stateful-tlv" {
@@ -347,11 +350,13 @@ module odl-pcep-ietf-stateful07 {
     augment "/topo:add-lsp/topo:input/topo:arguments" {
         ext:augment-identifier arguments-2;
         uses lsp-object;
+        uses pcep:path-setup-type-tlv;
     }
 
     augment "/topo:update-lsp/topo:input/topo:arguments" {
         ext:augment-identifier arguments-3;
         uses lsp-object;
+        uses pcep:path-setup-type-tlv;
     }
 
     typedef administrative-status {
index ddd650acd43a4b22f51e80809975bde933ddb388..de6fbe6744c3243ee10121c8e03e23545d38fad7 100644 (file)
@@ -60,6 +60,7 @@ 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.lspa.object.Lspa;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lspa.object.LspaBuilder;
 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.path.setup.type.tlv.PathSetupTypeBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.AttributeFilter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.Ipv4ExtendedTunnelId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.LspId;
@@ -221,4 +222,26 @@ public class PCEPObjectParserTest {
         parser.serializeObject(builder.build(), buf);
         assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
     }
+
+    @Test
+    public void testSRPObjectWithPSTTlv() throws PCEPDeserializerException {
+        final byte[] srpObjectWithPstTlvBytes = { 0x21, 0x10, 0x00, 0x14, 0x0, 0x0, 0x0, 0x01, 0x0, 0x0,
+            0x0, 0x01,
+            /* pst-tlv */
+            0x0, 0x1b, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0 };
+        final CInitiated00SrpObjectParser parser = new CInitiated00SrpObjectParser(this.tlvRegistry, this.viTlvRegistry);
+        SrpBuilder builder = new SrpBuilder();
+        builder.setProcessingRule(false);
+        builder.setIgnore(false);
+        builder.setOperationId(new SrpIdNumber(1L));
+        builder.addAugmentation(Srp1.class, new Srp1Builder().setRemove(true).build());
+        builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.srp.TlvsBuilder().setPathSetupType(new PathSetupTypeBuilder().setPst((short) 0).build()).build());
+
+        final ByteBuf result = Unpooled.wrappedBuffer(srpObjectWithPstTlvBytes);
+        assertEquals(builder.build(),
+                parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
+        final ByteBuf buf = Unpooled.buffer();
+        parser.serializeObject(builder.build(), buf);
+        assertArrayEquals(srpObjectWithPstTlvBytes, ByteArray.getAllBytes(buf));
+    }
 }
index fe138011b86d7f941aa3f434485fc03faff0702d..10c1bc4d0d25349a1e55132c22556596a1e1e382 100644 (file)
@@ -65,6 +65,7 @@ import org.opendaylight.protocol.pcep.impl.tlv.NoPathVectorTlvParser;
 import org.opendaylight.protocol.pcep.impl.tlv.OFListTlvParser;
 import org.opendaylight.protocol.pcep.impl.tlv.OrderTlvParser;
 import org.opendaylight.protocol.pcep.impl.tlv.OverloadedDurationTlvParser;
+import org.opendaylight.protocol.pcep.impl.tlv.PathSetupTypeTlvParser;
 import org.opendaylight.protocol.pcep.impl.tlv.ReqMissingTlvParser;
 import org.opendaylight.protocol.pcep.spi.EROSubobjectRegistry;
 import org.opendaylight.protocol.pcep.spi.LabelRegistry;
@@ -98,6 +99,7 @@ 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.Open;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.order.tlv.Order;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.overload.duration.tlv.OverloadDuration;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.ErrorObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.NoPath;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.no.path.tlvs.NoPathVector;
@@ -368,5 +370,9 @@ public final class Activator extends AbstractPCEPExtensionProviderActivator {
         final OrderTlvParser orderParser = new OrderTlvParser();
         regs.add(context.registerTlvParser(OrderTlvParser.TYPE, orderParser));
         regs.add(context.registerTlvSerializer(Order.class, orderParser));
+
+        final PathSetupTypeTlvParser pstParser = new PathSetupTypeTlvParser();
+        regs.add(context.registerTlvParser(PathSetupTypeTlvParser.TYPE, pstParser));
+        regs.add(context.registerTlvSerializer(PathSetupType.class, pstParser));
     }
 }
index 23499f851f17800e64cc1f29522fb80541e2d5b5..83c0544ca06462b3df8e84bc760f6ecc91b30492 100644 (file)
@@ -28,6 +28,7 @@ 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.RequestId;
 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.order.tlv.Order;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Rp;
 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.rp.object.rp.Tlvs;
@@ -132,6 +133,9 @@ public class PCEPRequestParameterObjectParser extends AbstractObjectWithTlvsPars
         if (tlv instanceof Order) {
             builder.setOrder((Order) tlv);
         }
+        if (tlv instanceof PathSetupType) {
+            builder.setPathSetupType((PathSetupType) tlv);
+        }
     }
 
     @Override
@@ -184,9 +188,13 @@ public class PCEPRequestParameterObjectParser extends AbstractObjectWithTlvsPars
     public void serializeTlvs(final Tlvs tlvs, final ByteBuf body) {
         if (tlvs == null) {
             return;
-        } else if (tlvs.getOrder() != null) {
+        }
+        if (tlvs.getOrder() != null) {
             serializeTlv(tlvs.getOrder(), body);
         }
+        if (tlvs.getPathSetupType() != null) {
+            serializeTlv(tlvs.getPathSetupType(), body);
+        }
         serializeVendorInformationTlvs(tlvs.getVendorInformationTlv(), body);
     }
 
similarity index 60%
rename from pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/lsp/setup/type01/PathSetupTypeTlvParser.java
rename to pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/tlv/PathSetupTypeTlvParser.java
index 2783fd1b45a7ff60dc43084d54c4608bd90bd552..b2e791868452b2ea2318e2e0d3b879b030b22a99 100644 (file)
@@ -5,46 +5,69 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-package org.opendaylight.protocol.pcep.lsp.setup.type01;
 
-import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeBoolean;
+package org.opendaylight.protocol.pcep.impl.tlv;
+
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
 
 import com.google.common.base.Preconditions;
+import com.google.common.collect.Sets;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
+import java.util.Set;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.TlvParser;
 import org.opendaylight.protocol.pcep.spi.TlvSerializer;
 import org.opendaylight.protocol.pcep.spi.TlvUtil;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.path.setup.type.tlv.PathSetupType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.path.setup.type.tlv.PathSetupTypeBuilder;
 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.path.setup.type.tlv.PathSetupType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupTypeBuilder;
 
 public class PathSetupTypeTlvParser implements TlvParser, TlvSerializer {
 
     // http://tools.ietf.org/html/draft-sivabalan-pce-segment-routing-01#section-9.3
     public static final int TYPE = 27;
+
     private static final int CONTENT_LENGTH = 4;
     private static final int PST_LENGTH = 1;
     private static final int OFFSET = CONTENT_LENGTH - PST_LENGTH;
+    private static final short RSVP_TE_PST = 0;
+    private static final String UNSUPPORTED_PST = "Unsupported path setup type.";
+
+    protected static final Set<Short> PSTS = Sets.newHashSet();
+
+    public PathSetupTypeTlvParser() {
+        PSTS.add(RSVP_TE_PST);
+    }
 
     @Override
-    public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
+    public void serializeTlv(Tlv tlv, ByteBuf buffer) {
         Preconditions.checkArgument(tlv instanceof PathSetupType, "PathSetupType is mandatory.");
         final PathSetupType pstTlv = (PathSetupType) tlv;
+        Preconditions.checkArgument(checkPST(pstTlv.getPst()), UNSUPPORTED_PST);
         ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
         body.writeZero(OFFSET);
-        writeBoolean(pstTlv.isPst(), body);
+        writeUnsignedByte(pstTlv.getPst(), body);
         TlvUtil.formatTlv(TYPE, body, buffer);
     }
 
     @Override
-    public Tlv parseTlv(final ByteBuf buffer) throws PCEPDeserializerException {
+    public Tlv parseTlv(ByteBuf buffer) throws PCEPDeserializerException {
         if (buffer == null) {
             return null;
         }
-        final boolean pst = buffer.readerIndex(OFFSET).readBoolean();
+        final short pst = buffer.readerIndex(OFFSET).readUnsignedByte();
+        if (!checkPST(pst)) {
+            throw new PCEPDeserializerException(UNSUPPORTED_PST);
+        }
         return new PathSetupTypeBuilder().setPst(pst).build();
     }
 
+    private boolean checkPST(final Short pst) {
+        if (pst != null) {
+            return PSTS.contains(pst);
+        }
+        return false;
+    }
+
 }
index 15e2823c8a21efdc8a034dd4bb49caad2ad55271..e463013ee02b83f7b4c23abe0311d7ff5d0f3bc6 100644 (file)
@@ -108,6 +108,7 @@ 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.path.key.object.PathKeyBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.key.object.path.key.PathKeys;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.key.object.path.key.PathKeysBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupTypeBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcc.id.req.object.PccIdReq;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcc.id.req.object.PccIdReqBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pce.id.object.PceIdBuilder;
@@ -1259,4 +1260,39 @@ public class PCEPObjectParserTest {
         parser.serializeObject(overload, buf);
         assertArrayEquals(overloadBytes, buf.array());
     }
+
+    @Test
+    public void testRpObjectWithPstTlvParser() throws PCEPDeserializerException {
+
+        final byte[] rpObjectWithPstTlvBytes = { 0x2, 0x10, 0x0, 0x14, 0x0, 0x0, 0x4, 0x2d, (byte) 0xde,
+            (byte) 0xad, (byte) 0xbe, (byte) 0xef,
+            /* pst-tlv */
+            0x0, 0x1b, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0 };
+
+        final PCEPRequestParameterObjectParser parser = new PCEPRequestParameterObjectParser(this.tlvRegistry, this.viTlvRegistry);
+        final RpBuilder builder = new RpBuilder();
+        builder.setProcessingRule(false);
+        builder.setIgnore(false);
+        builder.setReoptimization(true);
+        builder.setBiDirectional(false);
+        builder.setLoose(true);
+        builder.setMakeBeforeBreak(true);
+        builder.setOrder(false);
+        builder.setPathKey(false);
+        builder.setSupplyOf(false);
+        builder.setFragmentation(false);
+        builder.setP2mp(false);
+        builder.setEroCompression(false);
+        builder.setPriority((short) 5);
+        builder.setRequestId(new RequestId(0xdeadbeefL));
+        builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.rp.TlvsBuilder().setPathSetupType(
+                new PathSetupTypeBuilder().setPst((short) 0).build()).build());
+
+        final ByteBuf result = Unpooled.wrappedBuffer(rpObjectWithPstTlvBytes);
+        assertEquals(builder.build(),
+                parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
+        final ByteBuf buf = Unpooled.buffer();
+        parser.serializeObject(builder.build(), buf);
+        assertArrayEquals(rpObjectWithPstTlvBytes, ByteArray.getAllBytes(buf));
+    }
 }
index c35c0575b1437feb4d7b92f923e78c706878f38a..59178911624c361cbfc510b513dcd12216d0d8d5 100644 (file)
@@ -22,6 +22,7 @@ import org.opendaylight.protocol.pcep.impl.tlv.NoPathVectorTlvParser;
 import org.opendaylight.protocol.pcep.impl.tlv.OFListTlvParser;
 import org.opendaylight.protocol.pcep.impl.tlv.OrderTlvParser;
 import org.opendaylight.protocol.pcep.impl.tlv.OverloadedDurationTlvParser;
+import org.opendaylight.protocol.pcep.impl.tlv.PathSetupTypeTlvParser;
 import org.opendaylight.protocol.pcep.impl.tlv.ReqMissingTlvParser;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.util.ByteArray;
@@ -35,6 +36,8 @@ 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.order.tlv.OrderBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.overload.duration.tlv.OverloadDuration;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.overload.duration.tlv.OverloadDurationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupTypeBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.no.path.tlvs.NoPathVectorBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.req.missing.tlv.ReqMissing;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.req.missing.tlv.ReqMissingBuilder;
@@ -63,6 +66,10 @@ public class PCEPTlvParserTest {
         0x00, 0x00, 0x00, 0x05
     };
 
+    private static final byte[] PST_TLV_BYTES = { 0x0, 0x1b, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0 };
+
+    private static final byte[] PST_TLV_BYTES_UNSUPPORTED = { 0x0, 0x1b, 0x0, 0x4, 0x0, 0x0, 0x0, 0x1 };
+
     private final AbstractVendorSpecificTlvParser vsParser = new AbstractVendorSpecificTlvParser() {
 
         @Override
@@ -173,4 +180,28 @@ public class PCEPTlvParserTest {
         assertArrayEquals(VENDOR_INFO_BYTES, ByteArray.getAllBytes(buff));
         assertNull(parser.parseTlv(null));
     }
+
+    @Test
+    public void testPathSetupTypeTlvParser() throws PCEPDeserializerException {
+        final PathSetupTypeTlvParser parser = new PathSetupTypeTlvParser();
+        final PathSetupType pstTlv = new PathSetupTypeBuilder().setPst((short) 0).build();
+        assertEquals(pstTlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(PST_TLV_BYTES, 4))));
+        final ByteBuf buff = Unpooled.buffer();
+        parser.serializeTlv(pstTlv, buff);
+        assertArrayEquals(PST_TLV_BYTES, ByteArray.getAllBytes(buff));
+    }
+
+    @Test(expected=PCEPDeserializerException.class)
+    public void testUnsupportedPSTParser() throws PCEPDeserializerException {
+        final PathSetupTypeTlvParser parser = new PathSetupTypeTlvParser();
+        parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(PST_TLV_BYTES_UNSUPPORTED, 4)));
+    }
+
+    @Test(expected=IllegalArgumentException.class)
+    public void testUnsupportedPSTSerializer() {
+        final PathSetupTypeTlvParser parser = new PathSetupTypeTlvParser();
+        final PathSetupType pstTlv = new PathSetupTypeBuilder().setPst((short) 1).build();
+        final ByteBuf buff = Unpooled.buffer();
+        parser.serializeTlv(pstTlv, buff);
+    }
 }
diff --git a/pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/lsp/setup/type01/CInitiated00SrpObjectWithPstTlvParser.java b/pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/lsp/setup/type01/CInitiated00SrpObjectWithPstTlvParser.java
deleted file mode 100644 (file)
index 7d4f137..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.pcep.lsp.setup.type01;
-
-import io.netty.buffer.ByteBuf;
-import org.opendaylight.protocol.pcep.ietf.initiated00.CInitiated00SrpObjectParser;
-import org.opendaylight.protocol.pcep.spi.TlvRegistry;
-import org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.srp.Tlvs;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.srp.TlvsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.PathSetupTypeTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs5;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs6;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs7;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs7Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs8;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.path.setup.type.tlv.PathSetupType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv;
-
-public class CInitiated00SrpObjectWithPstTlvParser extends CInitiated00SrpObjectParser {
-
-    public CInitiated00SrpObjectWithPstTlvParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
-        super(tlvReg, viTlvReg);
-    }
-
-    @Override
-    public void addTlv(final TlvsBuilder builder, final Tlv tlv) {
-        super.addTlv(builder, tlv);
-        final Tlvs7Builder tlvBuilder = new Tlvs7Builder();
-        final Tlvs7 tlvs = builder.getAugmentation(Tlvs7.class);
-        if (tlvs != null && tlvs.getPathSetupType() != null) {
-            tlvBuilder.setPathSetupType(tlvs.getPathSetupType());
-        }
-        if (tlv instanceof PathSetupType) {
-            tlvBuilder.setPathSetupType((PathSetupType) tlv);
-        }
-        builder.addAugmentation(Tlvs7.class, tlvBuilder.build());
-    }
-
-    @Override
-    public void serializeTlvs(final Tlvs tlvs, final ByteBuf body) {
-        if (tlvs == null) {
-            return;
-        }
-        super.serializeTlvs(tlvs, body);
-        if (tlvs.getAugmentation(Tlvs5.class) != null) {
-            serializePathSetupType(tlvs.getAugmentation(Tlvs5.class), body);
-        } else if (tlvs.getAugmentation(Tlvs6.class) != null) {
-            serializePathSetupType(tlvs.getAugmentation(Tlvs6.class), body);
-        } else if (tlvs.getAugmentation(Tlvs7.class) != null) {
-            serializePathSetupType(tlvs.getAugmentation(Tlvs7.class), body);
-        } else if (tlvs.getAugmentation(Tlvs8.class) != null) {
-            serializePathSetupType(tlvs.getAugmentation(Tlvs8.class), body);
-        }
-    }
-
-    private void serializePathSetupType(final PathSetupTypeTlv pstTlv, final ByteBuf body) {
-        if (pstTlv.getPathSetupType() != null) {
-            serializeTlv(pstTlv.getPathSetupType(), body);
-        }
-    }
-}
diff --git a/pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/lsp/setup/type01/PcepRpObjectWithPstTlvParser.java b/pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/lsp/setup/type01/PcepRpObjectWithPstTlvParser.java
deleted file mode 100644 (file)
index 2c16114..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.pcep.lsp.setup.type01;
-
-import io.netty.buffer.ByteBuf;
-import org.opendaylight.protocol.pcep.impl.object.PCEPRequestParameterObjectParser;
-import org.opendaylight.protocol.pcep.spi.TlvRegistry;
-import org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.PathSetupTypeTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs1Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs2;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs3;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs4;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.path.setup.type.tlv.PathSetupType;
-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.rp.object.rp.Tlvs;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.rp.TlvsBuilder;
-
-public class PcepRpObjectWithPstTlvParser extends PCEPRequestParameterObjectParser {
-
-    public PcepRpObjectWithPstTlvParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
-        super(tlvReg, viTlvReg);
-    }
-
-    @Override
-    public void addTlv(final TlvsBuilder builder, final Tlv tlv) {
-        super.addTlv(builder, tlv);
-        final Tlvs1Builder tlvBuilder = new Tlvs1Builder();
-        final Tlvs1 tlvs = builder.getAugmentation(Tlvs1.class);
-        if (tlvs != null && tlvs.getPathSetupType() != null) {
-            tlvBuilder.setPathSetupType(tlvs.getPathSetupType());
-        }
-        if (tlv instanceof PathSetupType) {
-            tlvBuilder.setPathSetupType((PathSetupType) tlv);
-        }
-        builder.addAugmentation(Tlvs1.class, tlvBuilder.build()).build();
-    }
-
-    @Override
-    public void serializeTlvs(final Tlvs tlvs, final ByteBuf body) {
-        if (tlvs == null) {
-            return;
-        }
-        super.serializeTlvs(tlvs, body);
-        if (tlvs.getAugmentation(Tlvs1.class) != null) {
-            serializePathSetupType(tlvs.getAugmentation(Tlvs1.class), body);
-        } else if (tlvs.getAugmentation(Tlvs2.class) != null) {
-            serializePathSetupType(tlvs.getAugmentation(Tlvs2.class), body);
-        } else if (tlvs.getAugmentation(Tlvs3.class) != null) {
-            serializePathSetupType(tlvs.getAugmentation(Tlvs3.class), body);
-        } else if (tlvs.getAugmentation(Tlvs4.class) != null) {
-            serializePathSetupType(tlvs.getAugmentation(Tlvs4.class), body);
-        }
-    }
-
-    private void serializePathSetupType(final PathSetupTypeTlv pstTlv, final ByteBuf body) {
-        if (pstTlv.getPathSetupType() != null) {
-            serializeTlv(pstTlv.getPathSetupType(), body);
-        }
-    }
-}
index 37f465586fd0c900fd303292ea4afb5a6904081c..6b1712215427fbe9b69441b5d68a5137369b6d74 100644 (file)
@@ -10,9 +10,6 @@ package org.opendaylight.protocol.pcep.segment.routing02;
 
 import com.google.common.collect.Lists;
 import java.util.List;
-import org.opendaylight.protocol.pcep.lsp.setup.type01.CInitiated00SrpObjectWithPstTlvParser;
-import org.opendaylight.protocol.pcep.lsp.setup.type01.PathSetupTypeTlvParser;
-import org.opendaylight.protocol.pcep.lsp.setup.type01.PcepRpObjectWithPstTlvParser;
 import org.opendaylight.protocol.pcep.spi.ObjectRegistry;
 import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderContext;
 import org.opendaylight.protocol.pcep.spi.TlvRegistry;
@@ -22,13 +19,11 @@ import org.opendaylight.protocol.pcep.spi.pojo.AbstractPCEPExtensionProviderActi
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.Pcinitiate;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.Pcrpt;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.Pcupd;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.Srp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.path.setup.type.tlv.PathSetupType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Pcrep;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.add.lsp.input.arguments.ero.subobject.subobject.type.SrEroType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.sr.pce.capability.tlv.SrPceCapability;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Rp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupType;
 
 public class SegmentRoutingActivator extends AbstractPCEPExtensionProviderActivator {
 
@@ -38,9 +33,9 @@ public class SegmentRoutingActivator extends AbstractPCEPExtensionProviderActiva
 
         /* Tlvs */
         regs.add(context.registerTlvParser(SrPceCapabilityTlvParser.TYPE, new SrPceCapabilityTlvParser()));
-        regs.add(context.registerTlvParser(PathSetupTypeTlvParser.TYPE, new PathSetupTypeTlvParser()));
+        regs.add(context.registerTlvParser(SrPathSetupTypeTlvParser.TYPE, new SrPathSetupTypeTlvParser()));
 
-        regs.add(context.registerTlvSerializer(PathSetupType.class, new PathSetupTypeTlvParser()));
+        regs.add(context.registerTlvSerializer(PathSetupType.class, new SrPathSetupTypeTlvParser()));
         regs.add(context.registerTlvSerializer(SrPceCapability.class, new SrPceCapabilityTlvParser()));
 
         /* Subobjects */
@@ -50,15 +45,9 @@ public class SegmentRoutingActivator extends AbstractPCEPExtensionProviderActiva
         /* Objects */
         final TlvRegistry tlvReg = context.getTlvHandlerRegistry();
         final VendorInformationTlvRegistry viTlvRegistry = context.getVendorInformationTlvRegistry();
-        regs.add(context.registerObjectParser(CInitiated00SrpObjectWithPstTlvParser.CLASS,
-                CInitiated00SrpObjectWithPstTlvParser.TYPE, new CInitiated00SrpObjectWithPstTlvParser(tlvReg, viTlvRegistry)));
-        regs.add(context.registerObjectParser(PcepRpObjectWithPstTlvParser.CLASS, PcepRpObjectWithPstTlvParser.TYPE,
-                new PcepRpObjectWithPstTlvParser(tlvReg, viTlvRegistry)));
         regs.add(context.registerObjectParser(PcepOpenObjectWithSpcTlvParser.CLASS,
                 PcepOpenObjectWithSpcTlvParser.TYPE, new PcepOpenObjectWithSpcTlvParser(tlvReg, viTlvRegistry)));
 
-        regs.add(context.registerObjectSerializer(Srp.class, new CInitiated00SrpObjectWithPstTlvParser(tlvReg, viTlvRegistry)));
-        regs.add(context.registerObjectSerializer(Rp.class, new PcepRpObjectWithPstTlvParser(tlvReg, viTlvRegistry)));
         regs.add(context.registerObjectSerializer(Open.class, new PcepOpenObjectWithSpcTlvParser(tlvReg, viTlvRegistry)));
 
         /* Messages */
index efd369046bcbd2c83680ec464933775c9ac53a02..06d512b848901a0275ea420bbe1d557b383a159b 100644 (file)
@@ -10,15 +10,11 @@ package org.opendaylight.protocol.pcep.segment.routing02;
 
 import org.opendaylight.protocol.pcep.spi.PCEPErrors;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.Srp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.SrpBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.srp.TlvsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.PathSetupTypeTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs5;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs5Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.path.setup.type.tlv.PathSetupTypeBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.SrEroSubobject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Ero;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Rp;
 
 public final class SrEroUtil {
 
@@ -43,8 +39,15 @@ public final class SrEroUtil {
         return null;
     }
 
-    protected static boolean isPst(final PathSetupTypeTlv tlv) {
-        if (tlv != null && tlv.getPathSetupType() != null && tlv.getPathSetupType().isPst()) {
+    protected static boolean isSegmentRoutingPath(final Srp srp) {
+        if (srp != null && srp.getTlvs() != null && isSrTePst(srp.getTlvs().getPathSetupType())) {
+            return true;
+        }
+        return false;
+    }
+
+    protected static boolean isSegmentRoutingPath(final Rp rp) {
+        if (rp != null && rp.getTlvs() != null && isSrTePst(rp.getTlvs().getPathSetupType())) {
             return true;
         }
         return false;
@@ -62,9 +65,11 @@ public final class SrEroUtil {
         return false;
     }
 
-    protected static Srp addSRPathSetupTypeTlv(final Srp srp) {
-        return new SrpBuilder(srp).setTlvs(new TlvsBuilder(srp.getTlvs() != null ? srp.getTlvs() : new TlvsBuilder().build()).addAugmentation(Tlvs5.class,
-                new Tlvs5Builder().setPathSetupType(new PathSetupTypeBuilder().setPst(true).build()).build()).build()).build();
+    private static boolean isSrTePst(final PathSetupType tlv) {
+        if (tlv != null && tlv.getPst() == 1) {
+            return true;
+        }
+        return false;
     }
 
 }
diff --git a/pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/segment/routing02/SrPathSetupTypeTlvParser.java b/pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/segment/routing02/SrPathSetupTypeTlvParser.java
new file mode 100644 (file)
index 0000000..b46cd07
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.pcep.segment.routing02;
+
+import org.opendaylight.protocol.pcep.impl.tlv.PathSetupTypeTlvParser;
+
+public class SrPathSetupTypeTlvParser extends PathSetupTypeTlvParser {
+
+    private static final short SR_TE_PST = 1;
+
+    public SrPathSetupTypeTlvParser() {
+        super();
+        PSTS.add(SR_TE_PST);
+    }
+
+}
index 3b1a38499c20cdba8d7b2afa87998f777820dc0b..e9e5e4c8a8f57643e394ac49685d73af92e15654 100644 (file)
@@ -16,8 +16,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.cra
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.pcinitiate.message.pcinitiate.message.RequestsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.object.Lsp;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.Srp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs5;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs7;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Ero;
 
@@ -29,8 +27,8 @@ public class SrPcInitiateMessageParser extends CInitiated00PCInitiateMessagePars
 
     @Override
     protected void serializeRequest(final Requests req, final ByteBuf buffer) {
-        if (SrEroUtil.isSegmentRoutingPath(req.getEro())) {
-            serializeObject(SrEroUtil.addSRPathSetupTypeTlv(req.getSrp()), buffer);
+        if (SrEroUtil.isSegmentRoutingPath(req.getSrp()) || SrEroUtil.isSegmentRoutingPath(req.getEro())) {
+            serializeObject(req.getSrp(), buffer);
             serializeObject(req.getLsp(), buffer);
             serializeObject(req.getEro(), buffer);
         } else {
@@ -41,7 +39,7 @@ public class SrPcInitiateMessageParser extends CInitiated00PCInitiateMessagePars
     @Override
     protected Requests getValidRequest(final List<Object> objects) {
         final Srp srp = (Srp) objects.get(0);
-        if (isSegmentRoutingPath(srp)) {
+        if (SrEroUtil.isSegmentRoutingPath(srp)) {
             final RequestsBuilder builder = new RequestsBuilder();
             builder.setSrp(srp);
             objects.remove(0);
@@ -58,12 +56,4 @@ public class SrPcInitiateMessageParser extends CInitiated00PCInitiateMessagePars
         return super.getValidRequest(objects);
     }
 
-    private boolean isSegmentRoutingPath(final Srp srp) {
-        if (srp != null && srp.getTlvs() != null) {
-            return SrEroUtil.isPst(srp.getTlvs().getAugmentation(Tlvs5.class))
-                    || SrEroUtil.isPst(srp.getTlvs().getAugmentation(Tlvs7.class));
-        }
-        return false;
-    }
-
 }
index 144c1029dac51744d4a77342b421152490a00af0..0e8cabf15a7d02a26020b50e033b330c92afb084 100644 (file)
@@ -16,8 +16,6 @@ import org.opendaylight.protocol.pcep.impl.message.PCEPReplyMessageParser;
 import org.opendaylight.protocol.pcep.spi.ObjectRegistry;
 import org.opendaylight.protocol.pcep.spi.PCEPErrors;
 import org.opendaylight.protocol.pcep.spi.VendorInformationObjectRegistry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs2;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Ero;
@@ -40,7 +38,7 @@ public class SrPcRepMessageParser extends PCEPReplyMessageParser {
     @Override
     protected void serializeReply(Replies reply, ByteBuf buffer) {
         final Rp rp = reply.getRp();
-        if (isSegmentRoutingPath(rp)) {
+        if (SrEroUtil.isSegmentRoutingPath(rp)) {
             serializeObject(rp, buffer);
             if (reply.getResult() instanceof SuccessCase) {
                 final SuccessCase s = (SuccessCase) reply.getResult();
@@ -61,7 +59,7 @@ public class SrPcRepMessageParser extends PCEPReplyMessageParser {
             return null;
         }
         final Rp rp = (Rp) objects.get(0);
-        if (isSegmentRoutingPath(rp)) {
+        if (SrEroUtil.isSegmentRoutingPath(rp)) {
             objects.remove(0);
             Result res = null;
             if (objects.get(0) instanceof Ero) {
@@ -89,12 +87,4 @@ public class SrPcRepMessageParser extends PCEPReplyMessageParser {
         }
         return super.getValidReply(objects, errors);
     }
-
-    private boolean isSegmentRoutingPath(final Rp rp) {
-        if (rp.getTlvs() != null) {
-            return SrEroUtil.isPst(rp.getTlvs().getAugmentation(Tlvs1.class))
-                    || SrEroUtil.isPst(rp.getTlvs().getAugmentation(Tlvs2.class));
-        }
-        return false;
-    }
 }
index 9305f3a2225014f646d1f3ec7280bdbd3f34e59f..69dac2c561d6143c53e99c28093fdbb10f3ac56a 100644 (file)
@@ -22,7 +22,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.iet
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.pcrpt.message.pcrpt.message.ReportsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.pcrpt.message.pcrpt.message.reports.PathBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.Srp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs7;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Ero;
@@ -37,8 +36,8 @@ public class SrPcRptMessageParser extends Stateful07PCReportMessageParser {
 
     @Override
     protected void serializeReport(Reports report, ByteBuf buffer) {
-        if (report.getPath() != null && SrEroUtil.isSegmentRoutingPath(report.getPath().getEro())) {
-            serializeObject(SrEroUtil.addSRPathSetupTypeTlv(report.getSrp()), buffer);
+        if (report.getPath() != null && (SrEroUtil.isSegmentRoutingPath(report.getSrp()) || SrEroUtil.isSegmentRoutingPath(report.getPath().getEro()))) {
+            serializeObject(report.getSrp(), buffer);
             serializeObject(report.getLsp(), buffer);
             serializeObject(report.getPath().getEro(), buffer);
         } else {
@@ -50,7 +49,7 @@ public class SrPcRptMessageParser extends Stateful07PCReportMessageParser {
     protected Reports getValidReports(List<Object> objects, List<Message> errors) {
         if (objects.get(0) instanceof Srp) {
             final Srp srp = (Srp) objects.get(0);
-            if (isSegmentRoutingPath(srp)) {
+            if (SrEroUtil.isSegmentRoutingPath(srp)) {
                 boolean isValid = true;
                 final ReportsBuilder builder = new ReportsBuilder();
                 builder.setSrp(srp);
@@ -92,11 +91,4 @@ public class SrPcRptMessageParser extends Stateful07PCReportMessageParser {
         return super.getValidReports(objects, errors);
     }
 
-    private boolean isSegmentRoutingPath(final Srp srp) {
-        if (srp != null && srp.getTlvs() != null) {
-            return SrEroUtil.isPst(srp.getTlvs().getAugmentation(Tlvs7.class));
-        }
-        return false;
-    }
-
 }
index e64a71e791f8a6cc631fd3d0ddc896364c94cc48..e1b15329cbf1366665c6cf6b0d7109119f9e9b71 100644 (file)
@@ -19,8 +19,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.iet
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.pcupd.message.pcupd.message.UpdatesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.pcupd.message.pcupd.message.updates.PathBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.Srp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs6;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs7;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Ero;
@@ -34,8 +32,8 @@ public class SrPcUpdMessageParser extends Stateful07PCUpdateRequestMessageParser
 
     @Override
     protected void serializeUpdate(final Updates update, final ByteBuf buffer) {
-        if (update.getPath() != null && SrEroUtil.isSegmentRoutingPath(update.getPath().getEro())) {
-            serializeObject(SrEroUtil.addSRPathSetupTypeTlv(update.getSrp()), buffer);
+        if (update.getPath() != null && (SrEroUtil.isSegmentRoutingPath(update.getSrp()) || SrEroUtil.isSegmentRoutingPath(update.getPath().getEro()))) {
+            serializeObject(update.getSrp(), buffer);
             serializeObject(update.getLsp(), buffer);
             serializeObject(update.getPath().getEro(), buffer);
         } else {
@@ -45,7 +43,7 @@ public class SrPcUpdMessageParser extends Stateful07PCUpdateRequestMessageParser
 
     @Override
     protected Updates getValidUpdates(final List<Object> objects, final List<Message> errors) {
-        if (objects.get(0) instanceof Srp && isSegmentRoutingPath((Srp) objects.get(0))) {
+        if (objects.get(0) instanceof Srp && SrEroUtil.isSegmentRoutingPath((Srp) objects.get(0))) {
             boolean isValid = true;
             final Srp srp = (Srp) objects.get(0);
             final UpdatesBuilder builder = new UpdatesBuilder();
@@ -82,12 +80,4 @@ public class SrPcUpdMessageParser extends Stateful07PCUpdateRequestMessageParser
         return super.getValidUpdates(objects, errors);
     }
 
-    private boolean isSegmentRoutingPath(final Srp srp) {
-        if (srp != null && srp.getTlvs() != null) {
-            return SrEroUtil.isPst(srp.getTlvs().getAugmentation(Tlvs6.class))
-                    || SrEroUtil.isPst(srp.getTlvs().getAugmentation(Tlvs7.class));
-        }
-        return false;
-    }
-
 }
diff --git a/pcep/segment-routing/src/main/yang/odl-pcep-lsp-setup-type01.yang b/pcep/segment-routing/src/main/yang/odl-pcep-lsp-setup-type01.yang
deleted file mode 100644 (file)
index f5ab6e2..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-module odl-pcep-lsp-setup-type01 {
-    yang-version 1;
-    namespace "urn:opendaylight:params:xml:ns:yang:pcep:lsp:setup:type:01";
-    prefix "lst01";
-
-    import pcep-types { prefix pcep; revision-date 2013-10-05; }
-    import pcep-message { prefix msg; revision-date 2013-10-07; }
-    import odl-pcep-ietf-stateful07 { prefix stateful; revision-date 2013-12-22; }
-    import odl-pcep-ietf-initiated00 { prefix crabbe; revision-date 2013-11-26; }
-    import ietf-inet-types { prefix inet; revision-date 2010-09-24; }
-    import yang-ext { prefix ext; revision-date 2013-07-09; }
-
-    organization "Cisco Systems, Inc.";
-    contact "Milos Fabian <milfabia@cisco.com>";
-
-    description
-        "This module contains the data model of path setup type in PCEP messages,
-        draft-sivabalan-pce-lsp-setup-type-01.
-
-        Copyright (c)2014 Cisco Systems, Inc. All rights reserved.
-
-        This program and the accompanying materials are made available
-        under the terms of the Eclipse Public License v1.0 which
-        accompanies this distribution, and is available at
-        http://www.eclipse.org/legal/epl-v10.html";
-
-    revision "2014-05-07" {
-        description
-            "Initial revision.";
-        reference "http://tools.ietf.org/html/draft-sivabalan-pce-lsp-setup-type-01";
-    }
-
-    grouping path-setup-type-tlv {
-        description "PATH-SETUP-TYPE TLV";
-        reference "http://tools.ietf.org/html/draft-sivabalan-pce-lsp-setup-type-01#section-3";
-
-        container path-setup-type {
-            uses pcep:tlv;
-            leaf pst {
-                description "PST=0(false): Path is setup via RSVP-TE signaling protocol(default).
-                    PST=1(true): Path is setup using Segment Routing technique.";
-                type boolean;
-                default false;
-            }
-        }
-    }
-
-    augment "/msg:pcreq/msg:pcreq-message/msg:requests/msg:rp/msg:tlvs" {
-        reference "http://tools.ietf.org/html/draft-sivabalan-pce-lsp-setup-type-01#section-3";
-        uses path-setup-type-tlv;
-        ext:augment-identifier tlvs-1;
-    }
-
-    augment "/msg:pcrep/msg:pcrep-message/msg:replies/msg:rp/msg:tlvs" {
-        reference "http://tools.ietf.org/html/draft-sivabalan-pce-lsp-setup-type-01#section-3";
-        uses path-setup-type-tlv;
-        ext:augment-identifier tlvs-2;
-    }
-
-    augment "/msg:pcntf/msg:pcntf-message/msg:notifications/msg:rps/msg:rp/msg:tlvs" {
-        reference "http://tools.ietf.org/html/draft-sivabalan-pce-lsp-setup-type-01#section-3";
-        uses path-setup-type-tlv;
-        ext:augment-identifier tlvs-3;
-    }
-
-    augment "/msg:pcerr/msg:pcerr-message/msg:error-type/msg:request-case/msg:request/msg:rps/msg:rp/msg:tlvs" {
-        reference "http://tools.ietf.org/html/draft-sivabalan-pce-lsp-setup-type-01#section-3";
-        uses path-setup-type-tlv;
-        ext:augment-identifier tlvs-4;
-    }
-
-    augment "/crabbe:pcinitiate/crabbe:pcinitiate-message/crabbe:requests/crabbe:srp/crabbe:tlvs" {
-        reference "http://tools.ietf.org/html/draft-sivabalan-pce-lsp-setup-type-01#section-3";
-        uses path-setup-type-tlv;
-        ext:augment-identifier tlvs-5;
-    }
-
-    augment "/stateful:pcupd/stateful:pcupd-message/stateful:updates/stateful:srp/stateful:tlvs" {
-        reference "http://tools.ietf.org/html/draft-sivabalan-pce-lsp-setup-type-01#section-3";
-        uses path-setup-type-tlv;
-        ext:augment-identifier tlvs-6;
-    }
-
-    augment "/stateful:pcrpt/stateful:pcrpt-message/stateful:reports/stateful:srp/stateful:tlvs" {
-        reference "http://tools.ietf.org/html/draft-sivabalan-pce-lsp-setup-type-01#section-3";
-        uses path-setup-type-tlv;
-        ext:augment-identifier tlvs-7;
-    }
-
-    augment "/msg:pcerr/msg:pcerr-message/msg:error-type/stateful:stateful-case/stateful:stateful/stateful:srps/stateful:srp/stateful:tlvs" {
-        reference "http://tools.ietf.org/html/draft-sivabalan-pce-lsp-setup-type-01#section-3";
-        uses path-setup-type-tlv;
-        ext:augment-identifier tlvs-8;
-    }
-}
\ No newline at end of file
index 0e83cc9cb605cb0c4e0a298636aa5752df1d86db..987de917ae1addf65f3a852effee765b908152be 100644 (file)
@@ -10,7 +10,6 @@ module odl-pcep-segment-routing02 {
     import ietf-inet-types { prefix inet; revision-date 2010-09-24; }
     import network-topology { prefix nt; revision-date 2013-10-21; }
     import network-topology-pcep { prefix pn; revision-date 2013-10-24; }
-    import odl-pcep-lsp-setup-type01 { prefix lst01; revision-date 2014-05-07; }
     import rsvp { prefix rsvp; revision-date 2013-08-20; }
     import yang-ext { prefix ext; revision-date 2013-07-09; }
 
diff --git a/pcep/segment-routing/src/test/java/org/opendaylight/protocol/pcep/lsp/setup/type01/PcepObjectParserTest.java b/pcep/segment-routing/src/test/java/org/opendaylight/protocol/pcep/lsp/setup/type01/PcepObjectParserTest.java
deleted file mode 100644 (file)
index 6bd464e..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.protocol.pcep.lsp.setup.type01;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.protocol.pcep.segment.routing02.SegmentRoutingActivator;
-import org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl;
-import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.spi.TlvRegistry;
-import org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry;
-import org.opendaylight.protocol.pcep.spi.pojo.SimplePCEPExtensionProviderContext;
-import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.Srp1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.Srp1Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.SrpIdNumber;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.SrpBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs1Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs2;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs2Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs3;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs3Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs4;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs4Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs5;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs5Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs6;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs6Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs7;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs7Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs8;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs8Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.path.setup.type.tlv.PathSetupTypeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId;
-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.rp.object.rp.TlvsBuilder;
-
-public class PcepObjectParserTest {
-
-    private static final byte[] rpObjectWithPstTlvBytes = { 0x2, 0x10, 0x0, 0x14, 0x0, 0x0, 0x4, 0x2d, (byte) 0xde,
-        (byte) 0xad, (byte) 0xbe, (byte) 0xef,
-        /* pst-tlv */
-        0x0, 0x1b, 0x0, 0x4, 0x0, 0x0, 0x0, 0x1 };
-
-    private static final byte[] srpObjectWithPstTlvBytes = { 0x21, 0x10, 0x00, 0x14, 0x0, 0x0, 0x0, 0x01, 0x0, 0x0,
-        0x0, 0x01,
-        /* pst-tlv */
-        0x0, 0x1b, 0x0, 0x4, 0x0, 0x0, 0x0, 0x1 };
-
-    private TlvRegistry tlvRegistry;
-    private VendorInformationTlvRegistry viTlvRegistry;
-
-    private SimplePCEPExtensionProviderContext ctx;
-    private SegmentRoutingActivator act;
-
-    @Before
-    public void setUp() {
-        this.ctx = new SimplePCEPExtensionProviderContext();
-        this.act = new SegmentRoutingActivator();
-        this.act.start(this.ctx);
-        this.tlvRegistry = this.ctx.getTlvHandlerRegistry();
-        this.viTlvRegistry = this.ctx.getVendorInformationTlvRegistry();
-    }
-
-    @Test
-    public void testRpObjectWithPstTlvParser() throws PCEPDeserializerException {
-        final PcepRpObjectWithPstTlvParser parser = new PcepRpObjectWithPstTlvParser(this.tlvRegistry, this.viTlvRegistry);
-        final RpBuilder builder = new RpBuilder();
-        builder.setProcessingRule(false);
-        builder.setIgnore(false);
-        builder.setReoptimization(true);
-        builder.setBiDirectional(false);
-        builder.setLoose(true);
-        builder.setMakeBeforeBreak(true);
-        builder.setOrder(false);
-        builder.setPathKey(false);
-        builder.setSupplyOf(false);
-        builder.setFragmentation(false);
-        builder.setP2mp(false);
-        builder.setEroCompression(false);
-        builder.setPriority((short) 5);
-        builder.setRequestId(new RequestId(0xdeadbeefL));
-        builder.setTlvs(new TlvsBuilder().addAugmentation(Tlvs1.class,
-                new Tlvs1Builder().setPathSetupType(new PathSetupTypeBuilder().setPst(true).build()).build()).build());
-
-        final ByteBuf result = Unpooled.wrappedBuffer(rpObjectWithPstTlvBytes);
-        assertEquals(builder.build(),
-                parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
-        final ByteBuf buf = Unpooled.buffer();
-        parser.serializeObject(builder.build(), buf);
-        assertArrayEquals(rpObjectWithPstTlvBytes, ByteArray.getAllBytes(buf));
-
-        buf.clear();
-        builder.setTlvs(new TlvsBuilder().addAugmentation(Tlvs2.class,
-                new Tlvs2Builder().setPathSetupType(new PathSetupTypeBuilder().setPst(true).build()).build()).build());
-        parser.serializeObject(builder.build(), buf);
-        assertArrayEquals(rpObjectWithPstTlvBytes, ByteArray.getAllBytes(buf));
-
-        buf.clear();
-        builder.setTlvs(new TlvsBuilder().addAugmentation(Tlvs3.class,
-                new Tlvs3Builder().setPathSetupType(new PathSetupTypeBuilder().setPst(true).build()).build()).build());
-        parser.serializeObject(builder.build(), buf);
-        assertArrayEquals(rpObjectWithPstTlvBytes, ByteArray.getAllBytes(buf));
-
-        buf.clear();
-        builder.setTlvs(new TlvsBuilder().addAugmentation(Tlvs4.class,
-                new Tlvs4Builder().setPathSetupType(new PathSetupTypeBuilder().setPst(true).build()).build()).build());
-        parser.serializeObject(builder.build(), buf);
-        assertArrayEquals(rpObjectWithPstTlvBytes, ByteArray.getAllBytes(buf));
-    }
-
-    @Test
-    public void testSrpObjectWithPstTlvParser() throws PCEPDeserializerException {
-        final CInitiated00SrpObjectWithPstTlvParser parser = new CInitiated00SrpObjectWithPstTlvParser(this.tlvRegistry, this.viTlvRegistry);
-        SrpBuilder builder = new SrpBuilder();
-        builder.setProcessingRule(false);
-        builder.setIgnore(false);
-        builder.setOperationId(new SrpIdNumber(1L));
-        builder.addAugmentation(Srp1.class, new Srp1Builder().setRemove(true).build());
-        builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.srp.TlvsBuilder().addAugmentation(Tlvs7.class,
-                new Tlvs7Builder().setPathSetupType(new PathSetupTypeBuilder().setPst(true).build()).build())
-                .build());
-
-        final ByteBuf result = Unpooled.wrappedBuffer(srpObjectWithPstTlvBytes);
-        assertEquals(builder.build(),
-                parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
-        final ByteBuf buf = Unpooled.buffer();
-        parser.serializeObject(builder.build(), buf);
-        assertArrayEquals(srpObjectWithPstTlvBytes, ByteArray.getAllBytes(buf));
-
-        buf.clear();
-        builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.srp.TlvsBuilder().addAugmentation(Tlvs8.class,
-                new Tlvs8Builder().setPathSetupType(new PathSetupTypeBuilder().setPst(true).build()).build())
-                .build());
-        parser.serializeObject(builder.build(), buf);
-        assertArrayEquals(srpObjectWithPstTlvBytes, ByteArray.getAllBytes(buf));
-
-        buf.clear();
-        builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.srp.TlvsBuilder().addAugmentation(Tlvs6.class,
-                new Tlvs6Builder().setPathSetupType(new PathSetupTypeBuilder().setPst(true).build()).build())
-                .build());
-        parser.serializeObject(builder.build(), buf);
-        assertArrayEquals(srpObjectWithPstTlvBytes, ByteArray.getAllBytes(buf));
-
-        buf.clear();
-        builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.srp.TlvsBuilder().addAugmentation(Tlvs5.class,
-                new Tlvs5Builder().setPathSetupType(new PathSetupTypeBuilder().setPst(true).build()).build())
-                .build());
-        parser.serializeObject(builder.build(), buf);
-        assertArrayEquals(srpObjectWithPstTlvBytes, ByteArray.getAllBytes(buf));
-    }
-}
diff --git a/pcep/segment-routing/src/test/java/org/opendaylight/protocol/pcep/lsp/setup/type01/PcepTlvParserTest.java b/pcep/segment-routing/src/test/java/org/opendaylight/protocol/pcep/lsp/setup/type01/PcepTlvParserTest.java
deleted file mode 100644 (file)
index becc7e2..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.protocol.pcep.lsp.setup.type01;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-
-import org.junit.Test;
-import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
-import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.path.setup.type.tlv.PathSetupType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.path.setup.type.tlv.PathSetupTypeBuilder;
-
-public class PcepTlvParserTest {
-
-    private static final byte[] pstTlvBytes = { 0x0, 0x1b, 0x0, 0x4, 0x0, 0x0, 0x0, 0x1 };
-
-    @Test
-    public void testPathSetupTypeTlvParser() throws PCEPDeserializerException {
-        final PathSetupTypeTlvParser parser = new PathSetupTypeTlvParser();
-        final PathSetupType pstTlv = new PathSetupTypeBuilder().setPst(true).build();
-        assertEquals(pstTlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(pstTlvBytes, 4))));
-        final ByteBuf buff = Unpooled.buffer();
-        parser.serializeTlv(pstTlv, buff);
-        assertArrayEquals(pstTlvBytes, ByteArray.getAllBytes(buff));
-    }
-
-}
index 8bd42e85e77e5985cc240edce6a1901abe6fae11..1201fce49dc452561dbeb2823ec3822c11990f9c 100644 (file)
@@ -16,11 +16,6 @@ import java.util.List;
 import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.protocol.pcep.spi.PCEPErrors;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.Srp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.SrpBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs5;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs5Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.path.setup.type.tlv.PathSetupTypeBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.SrEroSubobject.Flags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.pcinitiate.pcinitiate.message.requests.ero.subobject.subobject.type.SrEroTypeBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Ero;
@@ -42,27 +37,11 @@ public class SrEroUtilTest {
         }
     }
 
-    @Test
-    public void testAddSRPathSetupTypeTlv() {
-        final SrpBuilder srpBuilder = new SrpBuilder();
-        final Srp srp = SrEroUtil.addSRPathSetupTypeTlv(srpBuilder.build());
-        Assert.assertTrue(srp.getTlvs().getAugmentation(Tlvs5.class).getPathSetupType().isPst());
-    }
-
-    @Test
-    public void testIsPst() {
-        Assert.assertTrue(SrEroUtil.isPst(new Tlvs5Builder().setPathSetupType(new PathSetupTypeBuilder().setPst(true).build()).build()));
-        Assert.assertFalse(SrEroUtil.isPst(new Tlvs5Builder().setPathSetupType(new PathSetupTypeBuilder().setPst(false).build()).build()));
-        Assert.assertFalse(SrEroUtil.isPst(null));
-        Assert.assertFalse(SrEroUtil.isPst(new Tlvs5Builder().build()));
-    }
-
     @Test
     public void testIsSegmentRoutingPath() {
         Assert.assertTrue(SrEroUtil.isSegmentRoutingPath(createEro(Lists.newArrayList(createSRSubobject()))));
         Assert.assertFalse(SrEroUtil.isSegmentRoutingPath(createEro(Collections.<Subobject>emptyList())));
         Assert.assertFalse(SrEroUtil.isSegmentRoutingPath(createEro(null)));
-        Assert.assertFalse(SrEroUtil.isSegmentRoutingPath(null));
         Assert.assertFalse(SrEroUtil.isSegmentRoutingPath(createEro(Lists.newArrayList(createIpPrefixSubobject()))));
     }
 
index 7c3f4b94372460ec0f730aee9b70e1d5888f78ee..fe093a32e72247a53b76e1aab7756ea7a0ff8284 100644 (file)
@@ -29,8 +29,6 @@ import org.opendaylight.protocol.pcep.spi.pojo.SimplePCEPExtensionProviderContex
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.PcinitiateBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.Srp1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.Srp1Builder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.pcinitiate.message.PcinitiateMessageBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.pcinitiate.message.pcinitiate.message.RequestsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.OperationalStatus;
@@ -48,11 +46,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.iet
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.pcupd.message.pcupd.message.updates.PathBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.Srp;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.SrpBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs1Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs7;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs7Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.path.setup.type.tlv.PathSetupTypeBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Pcerr;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcerrBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcrepBuilder;
@@ -66,6 +59,7 @@ 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.explicit.route.object.EroBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.SubobjectBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupTypeBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.ErrorObjectBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.PcerrMessageBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.ErrorsBuilder;
@@ -155,7 +149,7 @@ public class SrMessageParserTest {
             0x20,0x0C,0x00,0x30,
             /* srp-object */
             0x21,0x10,0x00,0x14,
-            0x00,0x00,0x00,0x001,
+            0x00,0x00,0x00,0x00,
             0x00,0x00,0x00,0x01,
             /* pst-tlv */
             0x00,0x1b,0x00,0x04,
@@ -168,7 +162,8 @@ public class SrMessageParserTest {
             /* sr-ero subobject */
             0x05,0x0c,(byte) 0x10,0x00,
             0x00,0x01,(byte) 0xe2,0x40,
-            0x4A,0x7D,0x2b,0x63};
+            0x4A,0x7D,0x2b,0x63
+        };
 
         final SrPcInitiateMessageParser parser = new SrPcInitiateMessageParser(objectRegistry);
 
@@ -195,7 +190,7 @@ public class SrMessageParserTest {
             0x20,0x0A,0x00,0x30,
             /* srp-object */
             0x21,0x10,0x00,0x14,
-            0x00,0x00,0x00,0x001,
+            0x00,0x00,0x00,0x00,
             0x00,0x00,0x00,0x01,
             /* pst-tlv */
             0x00,0x1b,0x00,0x04,
@@ -241,7 +236,7 @@ public class SrMessageParserTest {
             0x20,0x0B,0x00,0x30,
             /* srp-object */
             0x21,0x10,0x00,0x14,
-            0x00,0x00,0x00,0x001,
+            0x00,0x00,0x00,0x00,
             0x00,0x00,0x00,0x01,
             /* pst-tlv */
             0x00,0x1b,0x00,0x04,
@@ -279,7 +274,7 @@ public class SrMessageParserTest {
             0x20,0x0B,0x00,0x30,
             /* srp-object */
             0x21,0x10,0x00,0x14,
-            0x00,0x00,0x00,0x001,
+            0x00,0x00,0x00,0x00,
             0x00,0x00,0x00,0x01,
             /* pst-tlv */
             0x00,0x1b,0x00,0x04,
@@ -313,7 +308,7 @@ public class SrMessageParserTest {
             0x20,0x0A,0x00,0x30,
             /* srp-object */
             0x21,0x10,0x00,0x14,
-            0x00,0x00,0x00,0x001,
+            0x00,0x00,0x00,0x00,
             0x00,0x00,0x00,0x01,
             /* pst-tlv */
             0x00,0x1b,0x00,0x04,
@@ -380,21 +375,18 @@ public class SrMessageParserTest {
         rpBuilder.setEroCompression(false);
         rpBuilder.setPriority((short) 5);
         rpBuilder.setRequestId(new RequestId(0xdeadbeefL));
-        rpBuilder.setTlvs(new TlvsBuilder().addAugmentation(Tlvs1.class,
-                new Tlvs1Builder().setPathSetupType(new PathSetupTypeBuilder().setPst(true).build()).build()).build());
+        rpBuilder.setTlvs(new TlvsBuilder().setPathSetupType(new PathSetupTypeBuilder().setPst((short) 1).build()).build());
         return rpBuilder.build();
     }
 
-    private Srp createSrpObject() {;
+    private Srp createSrpObject() {
         final SrpBuilder builder = new SrpBuilder();
         builder.setProcessingRule(false);
         builder.setIgnore(false);
         builder.setOperationId(new SrpIdNumber(1L));
-        builder.addAugmentation(Srp1.class, new Srp1Builder().setRemove(true).build());
-        builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.srp.TlvsBuilder()
-                .addAugmentation(Tlvs7.class,
-                        new Tlvs7Builder().setPathSetupType(new PathSetupTypeBuilder().setPst(true).build()).build())
-                .build());
+        //builder.addAugmentation(Srp1.class, new Srp1Builder().setRemove(true).build());
+        builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.srp.TlvsBuilder().setPathSetupType(
+                new PathSetupTypeBuilder().setPst((short) 1).build()).build());
         return builder.build();
     }
 
index 0a0fb350e1b9dea79ad849786ef2fbdf20a259ab..2b4f31618a3d395ac8fad1e78954598404842406 100644 (file)
@@ -10,27 +10,41 @@ package org.opendaylight.protocol.pcep.segment.routing02;
 
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
+
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
-
 import org.junit.Test;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.sr.pce.capability.tlv.SrPceCapability;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.sr.pce.capability.tlv.SrPceCapabilityBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupTypeBuilder;
 
 public class SrTlvParserTest {
 
-    private static final byte[] spcTlvBytes = { 0x0, 0x1a, 0x0, 0x4, 0x0, 0x0, 0x0, 0x1 };
+    private static final byte[] SPC_TLV_BYTES = { 0x0, 0x1a, 0x0, 0x4, 0x0, 0x0, 0x0, 0x1 };
+
+    private static final byte[] SR_TE_PST_BYTES = { 0x0, 0x1b, 0x0, 0x4, 0x0, 0x0, 0x0, 0x1 };
 
     @Test
     public void testSrPceCapabilityParser() throws PCEPDeserializerException {
         final SrPceCapabilityTlvParser parser = new SrPceCapabilityTlvParser();
         final SrPceCapability spcTlv = new SrPceCapabilityBuilder().setMsd((short) 1).build();
-        assertEquals(spcTlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(spcTlvBytes, 4))));
+        assertEquals(spcTlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(SPC_TLV_BYTES, 4))));
         final ByteBuf buff = Unpooled.buffer();
         parser.serializeTlv(spcTlv, buff);
-        assertArrayEquals(spcTlvBytes, ByteArray.getAllBytes(buff));
+        assertArrayEquals(SPC_TLV_BYTES, ByteArray.getAllBytes(buff));
+    }
+
+    @Test
+    public void testPathSetupTypeTlvParser() throws PCEPDeserializerException {
+        final SrPathSetupTypeTlvParser parser = new SrPathSetupTypeTlvParser();
+        final PathSetupType pstTlv = new PathSetupTypeBuilder().setPst((short) 1).build();
+        assertEquals(pstTlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(SR_TE_PST_BYTES, 4))));
+        final ByteBuf buff = Unpooled.buffer();
+        parser.serializeTlv(pstTlv, buff);
+        assertArrayEquals(SR_TE_PST_BYTES, ByteArray.getAllBytes(buff));
     }
 
 }
index b070a8e618af3ac2f221a1e1eb330f5eb62f7281..b8e63269216643d189ace59881327601834d664e 100644 (file)
@@ -20,6 +20,7 @@ import org.opendaylight.bgpcep.pcep.topology.provider.AbstractTopologySessionLis
 import org.opendaylight.bgpcep.pcep.topology.provider.Stateful07TopologySessionListenerFactory;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.Path1;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.Pcrpt;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.PcrptBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.PlspId;
@@ -43,6 +44,7 @@ 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.explicit.route.object.EroBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.SubobjectBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupTypeBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.LspId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.Node1;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.path.computation.client.ReportedLsp;
@@ -71,6 +73,7 @@ public class TopologyProviderTest extends AbstractPCEPSessionTest<Stateful07Topo
         Assert.assertEquals(1, reportedLsps.size());
         final ReportedLsp lsp = reportedLsps.get(0);
         Assert.assertEquals("sr-path1", lsp.getName());
+        Assert.assertEquals(1, lsp.getPath().get(0).getAugmentation(Path1.class).getPathSetupType().getPst().intValue());
         List<Subobject> subobjects = lsp.getPath().get(0).getEro().getSubobject();
         Assert.assertEquals(1, subobjects.size());
         Assert.assertEquals("1.1.1.1", ((IpNodeId)((SrEroType)subobjects.get(0).getSubobjectType()).getNai()).getIpAddress().getIpv4Address().getValue());
@@ -103,7 +106,9 @@ public class TopologyProviderTest extends AbstractPCEPSessionTest<Stateful07Topo
                     .setTlvs(new TlvsBuilder()
                         .setLspIdentifiers(new LspIdentifiersBuilder().setLspId(new LspId(plspId)).build())
                         .setSymbolicPathName(new SymbolicPathNameBuilder().setPathName(new SymbolicPathName(pathName.getBytes(Charsets.UTF_8))).build()).build()).build())
-            .setSrp(new SrpBuilder().setOperationId(new SrpIdNumber(0L)).build())
+            .setSrp(new SrpBuilder().setOperationId(new SrpIdNumber(0L)).setTlvs(
+                    new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.srp.TlvsBuilder()
+                        .setPathSetupType(new PathSetupTypeBuilder().setPst((short) 1).build()).build()).build())
             .setPath(new PathBuilder().setEro(createSrEroObject(nai)).build())
             .build())).build()).build();
     }
index 6751cc94ae2b46c40312a3fd252e271215d9f26c..7213c02d77bcad5dcd9584dcb82739a971687b61 100644 (file)
@@ -266,8 +266,16 @@ public enum PCEPErrors {
     NON_IDENTICAL_ERO_SUBOBJECTS(10, 5),
     /**
      * Segment Routing error: ERO subobject with invalid SID value;
-     * */
-    BAD_LABEL_VALUE(10, 2);
+     */
+    BAD_LABEL_VALUE(10, 2),
+    /**
+     * Invalid traffic engineering path setup type: Unsupported path setup type
+     */
+    UNSUPPORTED_PST(21, 1),
+    /**
+     * Invalid traffic engineering path setup type: Mismatched path setup type
+     */
+    MISMATCHED_PST(21, 2);
 
     private PCEPErrorIdentifier errorId;
     private static final Map<PCEPErrorIdentifier, PCEPErrors> VALUE_MAP;
index 5bbb52d76ec1bf45c062226cecb8ff497301cb43..6a53143282e128a7c4c10852a0f616f8eed4910f 100644 (file)
@@ -60,6 +60,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.iet
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcerrMessage;
 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.path.setup.type.tlv.PathSetupType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.AddLspArgs;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.EnsureLspOperationalInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.LspId;
@@ -192,7 +193,12 @@ final class Stateful07TopologySessionListener extends AbstractTopologySessionLis
             }
             // LSP is mandatory (if there is none, parser will throw an exception)
             // this is to ensure a path will be created at any rate
-            pb.addAugmentation(Path1.class, new Path1Builder().setLsp(report.getLsp()).build());
+            final Path1Builder p1Builder = new Path1Builder();
+            p1Builder.setLsp(report.getLsp());
+            if (srp != null && srp.getTlvs() != null && srp.getTlvs().getPathSetupType() != null) {
+                p1Builder.setPathSetupType(srp.getTlvs().getPathSetupType());
+            }
+            pb.addAugmentation(Path1.class, p1Builder.build());
             String name = lookupLspName(plspid);
             final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.object.lsp.Tlvs tlvs = report.getLsp().getTlvs();
             if (tlvs != null) {
@@ -252,7 +258,16 @@ final class Stateful07TopologySessionListener extends AbstractTopologySessionLis
                     tlvsBuilder.setVsTlv(inputLsp.getTlvs().getVsTlv());
                 }
 
-                rb.setSrp(new SrpBuilder().setOperationId(nextRequest()).setProcessingRule(Boolean.TRUE).build());
+                final SrpBuilder srpBuilder = new SrpBuilder();
+                srpBuilder.setOperationId(nextRequest());
+                srpBuilder.setProcessingRule(Boolean.TRUE);
+                if (!isDefaultPST(args.getPathSetupType())) {
+                    srpBuilder.setTlvs(
+                            new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.srp.TlvsBuilder()
+                                .setPathSetupType(args.getPathSetupType()).build());
+                }
+                rb.setSrp(srpBuilder.build());
+
                 rb.setLsp(new LspBuilder().setAdministrative(inputLsp.isAdministrative()).setDelegate(inputLsp.isDelegate()).setPlspId(
                     new PlspId(0L)).setTlvs(tlvsBuilder.build()).build());
 
@@ -286,7 +301,14 @@ final class Stateful07TopologySessionListener extends AbstractTopologySessionLis
                 }
                 // Build the request and send it
                 final RequestsBuilder rb = new RequestsBuilder();
-                rb.setSrp(new SrpBuilder().addAugmentation(Srp1.class, new Srp1Builder().setRemove(Boolean.TRUE).build()).setOperationId(nextRequest()).setProcessingRule(Boolean.TRUE).build());
+                final SrpBuilder srpBuilder = new SrpBuilder().addAugmentation(Srp1.class, new Srp1Builder().setRemove(Boolean.TRUE).build()).setOperationId(nextRequest()).setProcessingRule(Boolean.TRUE);
+                final Optional<PathSetupType> maybePST = getPST(rep);
+                if (maybePST.isPresent()) {
+                    srpBuilder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.srp.TlvsBuilder()
+                        .setPathSetupType(maybePST.get())
+                        .build());
+                }
+                rb.setSrp(srpBuilder.build());
                 rb.setLsp(new LspBuilder().setRemove(Boolean.FALSE).setPlspId(reportedLsp.getPlspId()).setDelegate(reportedLsp.isDelegate()).build());
 
                 final PcinitiateMessageBuilder ib = new PcinitiateMessageBuilder(MESSAGE_HEADER);
@@ -315,9 +337,27 @@ final class Stateful07TopologySessionListener extends AbstractTopologySessionLis
                     return OperationResults.createUnsent(PCEPErrors.UNKNOWN_PLSP_ID).future();
                 }
                 // create mandatory objects
-                final Srp srp = new SrpBuilder().setOperationId(nextRequest()).setProcessingRule(Boolean.TRUE).build();
+                final Arguments3 args = input.getArguments().getAugmentation(Arguments3.class);
+                final SrpBuilder srpBuilder = new SrpBuilder();
+                srpBuilder.setOperationId(nextRequest());
+                srpBuilder.setProcessingRule(Boolean.TRUE);
+                if (args != null && args.getPathSetupType() != null) {
+                    if (!isDefaultPST(args.getPathSetupType())) {
+                        srpBuilder.setTlvs(
+                                new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.srp.TlvsBuilder()
+                                    .setPathSetupType(args.getPathSetupType()).build());
+                    }
+                } else {
+                    final Optional<PathSetupType> maybePST = getPST(rep);
+                    if (maybePST.isPresent()) {
+                        srpBuilder.setTlvs(
+                                new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.srp.TlvsBuilder()
+                                    .setPathSetupType(maybePST.get()).build());
+                    }
+                }
+                final Srp srp = srpBuilder.build();
 
-                final Lsp inputLsp = input.getArguments().getAugmentation(Arguments3.class).getLsp();
+                final Lsp inputLsp = args.getLsp();
                 final Lsp lsp = (inputLsp != null) ?
                     new LspBuilder().setPlspId(reportedLsp.getPlspId()).setDelegate((inputLsp.isDelegate() != null) ? inputLsp.isDelegate() : false).setTlvs(inputLsp.getTlvs()).setAdministrative((inputLsp.isAdministrative() != null) ? inputLsp.isAdministrative() : false).build()
                     : new LspBuilder().setPlspId(reportedLsp.getPlspId()).build();
@@ -411,6 +451,26 @@ final class Stateful07TopologySessionListener extends AbstractTopologySessionLis
         return reportedLsp;
     }
 
+    private Optional<PathSetupType> getPST(final Optional<ReportedLsp> rep) {
+        if (rep.isPresent()) {
+            final Path1 path1 = rep.get().getPath().get(0).getAugmentation(Path1.class);
+            if (path1 != null) {
+                final PathSetupType pst = path1.getPathSetupType();
+                if (!isDefaultPST(pst)) {
+                    return Optional.of(pst);
+                }
+            }
+        }
+        return Optional.absent();
+    }
+
+    private static boolean isDefaultPST(final PathSetupType pst) {
+        if (pst != null && pst.getPst() != null && pst.getPst().shortValue() != 0) {
+            return false;
+        }
+        return true;
+    }
+
     private static PeerCapabilities getCapabilities(final Stateful stateful) {
         final PeerCapabilities capa = new PeerCapabilities();
         capa.setStateful(true);