}
}
+ 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";
container "tlvs" {
uses order-tlv;
uses vendor-information-tlvs;
+ uses path-setup-type-tlv;
}
leaf priority {
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;
/**
if (tlv instanceof SymbolicPathName) {
builder.setSymbolicPathName((SymbolicPathName) tlv);
}
+ if (tlv instanceof PathSetupType) {
+ builder.setPathSetupType((PathSetupType) tlv);
+ }
}
@Override
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
uses symbolic-path-name-tlv;
uses pcep:vendor-information-tlvs;
+
+ uses pcep:path-setup-type-tlv;
}
leaf operation-id {
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" {
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 {
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;
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));
+ }
}
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;
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;
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));
}
}
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;
if (tlv instanceof Order) {
builder.setOrder((Order) tlv);
}
+ if (tlv instanceof PathSetupType) {
+ builder.setPathSetupType((PathSetupType) tlv);
+ }
}
@Override
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);
}
* 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;
+ }
+
}
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;
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));
+ }
}
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;
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;
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
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);
+ }
}
+++ /dev/null
-/*
- * 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);
- }
- }
-}
+++ /dev/null
-/*
- * 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);
- }
- }
-}
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;
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 {
/* 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 */
/* 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 */
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 {
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;
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;
}
}
--- /dev/null
+/*
+ * 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);
+ }
+
+}
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;
@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 {
@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);
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;
- }
-
}
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;
@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();
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) {
}
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;
- }
}
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;
@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 {
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);
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;
- }
-
}
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;
@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 {
@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();
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;
- }
-
}
+++ /dev/null
-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
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; }
+++ /dev/null
-/*
- * 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));
- }
-}
+++ /dev/null
-/*
- * 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));
- }
-
-}
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;
}
}
- @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()))));
}
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;
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;
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;
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,
/* 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);
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,
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,
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,
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,
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();
}
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));
}
}
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;
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;
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());
.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();
}
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;
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;
}
// 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) {
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());
}
// 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);
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();
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);