}
}
+ grouping vendor-information {
+ description "VENDOR-INFORMATION format";
+ reference "http://tools.ietf.org/html/draft-ietf-pce-rfc7150bis-00#section-4";
+
+ leaf enterprise-number {
+ type iana:enterprise-number;
+ }
+
+ choice enterprise-specific-information {
+ }
+ }
+
// TLVs
grouping tlv {
description "Marker grouping for TLV groupings.";
uses object-header;
}
+ grouping vendor-information-tlvs {
+ list vendor-information-tlv {
+ description "VENDOR-INFORMATION-TLV";
+ reference "http://tools.ietf.org/html/draft-ietf-pce-rfc7150bis-00#section-3";
+ uses tlv;
+ uses vendor-information;
+ }
+ }
+
grouping open-object {
description "OPEN Object";
reference "https://tools.ietf.org/html/rfc5440#section-7.3";
uses object;
container "tlvs" {
uses of-list-tlv;
+ uses vendor-information-tlvs;
}
leaf version {
uses object;
container "tlvs" {
uses order-tlv;
+ uses vendor-information-tlvs;
}
leaf priority {
uses object;
uses rsvp:tunnel-attributes;
container "tlvs" {
+ uses vendor-information-tlvs;
}
}
}
when "../type = 2 and ../value = 1";
uses overload-duration-tlv;
+ uses vendor-information-tlvs;
}
leaf type {
container "tlvs" {
when "../type = 7";
uses req-missing-tlv;
+ uses vendor-information-tlvs;
}
leaf type {
}
container tlvs {
-
+ uses vendor-information-tlvs;
}
}
}
type of-id;
mandatory true;
}
+
+ container tlvs {
+ uses vendor-information-tlvs;
+ }
}
}
units percent;
mandatory true;
}
+
+ container tlvs {
+ uses vendor-information-tlvs;
+ }
}
}
container no-path {
uses no-path-object;
container "tlvs" {
+ uses vendor-information-tlvs;
container no-path-vector {
uses no-path-vector-tlv;
}
import java.util.ArrayList;
import java.util.List;
-
import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderContext;
import org.opendaylight.protocol.pcep.spi.pojo.AbstractPCEPExtensionProviderActivator;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated._00.rev140113.Pcinitiate;
regs.add(context.registerMessageSerializer(Pcinitiate.class, new PcinitiateMessageParser(context.getObjectHandlerRegistry())));
regs.add(context.registerObjectParser(PCEPOpenObjectParser.CLASS, PCEPOpenObjectParser.TYPE,
- new PCEPOpenObjectParser(context.getTlvHandlerRegistry())));
- regs.add(context.registerObjectSerializer(Open.class, new PCEPOpenObjectParser(context.getTlvHandlerRegistry())));
+ new PCEPOpenObjectParser(context.getTlvHandlerRegistry(), context.getVendorInformationTlvRegistry())));
+ regs.add(context.registerObjectSerializer(Open.class, new PCEPOpenObjectParser(context.getTlvHandlerRegistry(),
+ context.getVendorInformationTlvRegistry())));
regs.add(context.registerTlvParser(LSPCleanupTlvParser.TYPE, new LSPCleanupTlvParser()));
regs.add(context.registerTlvSerializer(LspCleanup.class, new LSPCleanupTlvParser()));
package org.opendaylight.protocol.pcep.crabbe.initiated00;
import io.netty.buffer.ByteBuf;
-
import org.opendaylight.protocol.pcep.ietf.stateful02.Stateful02OpenObjectParser;
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.crabbe.initiated._00.rev140113.Tlvs1;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated._00.rev140113.Tlvs1Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated._00.rev140113.lsp.cleanup.tlv.LspCleanup;
*/
public final class PCEPOpenObjectParser extends Stateful02OpenObjectParser {
- public PCEPOpenObjectParser(final TlvRegistry tlvReg) {
- super(tlvReg);
+ public PCEPOpenObjectParser(TlvRegistry tlvReg, VendorInformationTlvRegistry viTlvReg) {
+ super(tlvReg, viTlvReg);
}
@Override
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.util.BitSet;
+import java.util.List;
import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
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.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.stateful._02.rev140110.PlspId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.stateful._02.rev140110.lsp.db.version.tlv.LspDbVersion;
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.vendor.information.tlvs.VendorInformationTlv;
/**
* Parser for {@link Lsp}
private static final int FLAGS_SIZE = 2;
- public Stateful02LspObjectParser(final TlvRegistry tlvReg) {
- super(tlvReg);
+ public Stateful02LspObjectParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
+ super(tlvReg, viTlvReg);
}
@Override
if (tlvs.getLspDbVersion() != null) {
serializeTlv(tlvs.getLspDbVersion(), body);
}
+ serializeVendorInformationTlvs(tlvs.getVendorInformationTlv(), body);
+ }
+
+ @Override
+ protected final void addVendorInformationTlvs(final TlvsBuilder builder, final List<VendorInformationTlv> tlvs) {
+ if (!tlvs.isEmpty()) {
+ builder.setVendorInformationTlv(tlvs);
+ }
}
}
package org.opendaylight.protocol.pcep.ietf.stateful02;
import io.netty.buffer.ByteBuf;
-
import org.opendaylight.protocol.pcep.impl.object.PCEPLspaObjectParser;
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.crabbe.initiated._00.rev140113.Tlvs2;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated._00.rev140113.Tlvs2Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.stateful._02.rev140110.symbolic.path.name.tlv.SymbolicPathName;
*/
public class Stateful02LspaObjectParser extends PCEPLspaObjectParser {
- public Stateful02LspaObjectParser(final TlvRegistry tlvReg) {
- super(tlvReg);
+ public Stateful02LspaObjectParser(TlvRegistry tlvReg, VendorInformationTlvRegistry viTlvReg) {
+ super(tlvReg, viTlvReg);
}
@Override
package org.opendaylight.protocol.pcep.ietf.stateful02;
import io.netty.buffer.ByteBuf;
-
import org.opendaylight.protocol.pcep.impl.object.PCEPOpenObjectParser;
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.crabbe.stateful._02.rev140110.Tlvs2;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.stateful._02.rev140110.Tlvs2Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.stateful._02.rev140110.node.identifier.tlv.NodeIdentifier;
*/
public class Stateful02OpenObjectParser extends PCEPOpenObjectParser {
- public Stateful02OpenObjectParser(final TlvRegistry tlvReg) {
- super(tlvReg);
+ public Stateful02OpenObjectParser(TlvRegistry tlvReg, VendorInformationTlvRegistry viTlvReg) {
+ super(tlvReg, viTlvReg);
}
@Override
import java.util.ArrayList;
import java.util.List;
-
import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderContext;
import org.opendaylight.protocol.pcep.spi.pojo.AbstractPCEPExtensionProviderActivator;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.stateful._02.rev140110.Pcrpt;
regs.add(context.registerMessageSerializer(Pcreq.class, new Stateful02PCRequestMessageParser(context.getObjectHandlerRegistry())));
regs.add(context.registerObjectParser(Stateful02LspObjectParser.CLASS, Stateful02LspObjectParser.TYPE,
- new Stateful02LspObjectParser(context.getTlvHandlerRegistry())));
- regs.add(context.registerObjectSerializer(Lsp.class, new Stateful02LspObjectParser(context.getTlvHandlerRegistry())));
+ new Stateful02LspObjectParser(context.getTlvHandlerRegistry(), context.getVendorInformationTlvRegistry())));
+ regs.add(context.registerObjectSerializer(Lsp.class, new Stateful02LspObjectParser(context.getTlvHandlerRegistry(),
+ context.getVendorInformationTlvRegistry())));
regs.add(context.registerObjectParser(Stateful02OpenObjectParser.CLASS, Stateful02OpenObjectParser.TYPE,
- new Stateful02OpenObjectParser(context.getTlvHandlerRegistry())));
- regs.add(context.registerObjectSerializer(Open.class, new Stateful02OpenObjectParser(context.getTlvHandlerRegistry())));
+ new Stateful02OpenObjectParser(context.getTlvHandlerRegistry(), context.getVendorInformationTlvRegistry())));
+ regs.add(context.registerObjectSerializer(Open.class, new Stateful02OpenObjectParser(context.getTlvHandlerRegistry(),
+ context.getVendorInformationTlvRegistry())));
regs.add(context.registerObjectParser(Stateful02LspaObjectParser.CLASS, Stateful02LspaObjectParser.TYPE,
- new Stateful02LspaObjectParser(context.getTlvHandlerRegistry())));
- regs.add(context.registerObjectSerializer(Lspa.class, new Stateful02LspaObjectParser(context.getTlvHandlerRegistry())));
+ new Stateful02LspaObjectParser(context.getTlvHandlerRegistry(),
+ context.getVendorInformationTlvRegistry())));
+ regs.add(context.registerObjectSerializer(Lspa.class, new Stateful02LspaObjectParser(context.getTlvHandlerRegistry(),
+ context.getVendorInformationTlvRegistry())));
regs.add(context.registerTlvParser(Stateful02StatefulCapabilityTlvParser.TYPE, new Stateful02StatefulCapabilityTlvParser()));
regs.add(context.registerTlvSerializer(Stateful.class, new Stateful02StatefulCapabilityTlvParser()));
uses rsvp-error-spec-tlv;
uses symbolic-path-name-tlv;
+
+ uses pcep:vendor-information-tlvs;
}
leaf plsp-id {
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
+
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import java.io.IOException;
-
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.protocol.pcep.crabbe.initiated00.PCEPOpenObjectParser;
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.ServiceLoaderPCEPExtensionProviderContext;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated._00.rev140113.Stateful1;
private TlvRegistry tlvRegistry;
+ private VendorInformationTlvRegistry viTlvRegistry;
+
@Before
public void setUp() throws Exception {
this.tlvRegistry = ServiceLoaderPCEPExtensionProviderContext.create().getTlvHandlerRegistry();
+ this.viTlvRegistry = ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance().getVendorInformationTlvRegistry();
}
@Test
public void testOpenObjectWithTLV() throws PCEPDeserializerException, IOException {
- final PCEPOpenObjectParser parser = new PCEPOpenObjectParser(this.tlvRegistry);
+ final PCEPOpenObjectParser parser = new PCEPOpenObjectParser(this.tlvRegistry, this.viTlvRegistry);
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPOpenObject1.bin"));
final OpenBuilder builder = new OpenBuilder();
@Test
public void testLspaObjectWithTlv() throws IOException, PCEPDeserializerException {
- final Stateful02LspaObjectParser parser = new Stateful02LspaObjectParser(this.tlvRegistry);
+ final Stateful02LspaObjectParser parser = new Stateful02LspaObjectParser(this.tlvRegistry, this.viTlvRegistry);
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspaObject1LowerBounds.bin"));
final LspaBuilder builder = new LspaBuilder();
@Test
public void testLspObjectWithTLV() throws IOException, PCEPDeserializerException {
- final Stateful02LspObjectParser parser = new Stateful02LspObjectParser(this.tlvRegistry);
+ final Stateful02LspObjectParser parser = new Stateful02LspObjectParser(this.tlvRegistry, this.viTlvRegistry);
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspObject1WithTLV.bin"));
final LspBuilder builder = new LspBuilder();
package org.opendaylight.protocol.pcep.ietf.initiated00;
import com.google.common.base.Preconditions;
-
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import java.util.BitSet;
-
import org.opendaylight.protocol.pcep.ietf.stateful07.Stateful07LspObjectParser;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
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.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.Lsp1;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.Lsp1Builder;
private static final int CREATE_FLAG_OFFSET = 8;
- public CInitiated00LspObjectParser(final TlvRegistry tlvReg) {
- super(tlvReg);
+ public CInitiated00LspObjectParser(TlvRegistry tlvReg, VendorInformationTlvRegistry viTlvReg) {
+ super(tlvReg, viTlvReg);
}
@Override
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
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.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.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.types.rev131005.Object;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
private static final int REMOVE_FLAG = 31;
- public CInitiated00SrpObjectParser(final TlvRegistry tlvReg) {
- super(tlvReg);
+ public CInitiated00SrpObjectParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
+ super(tlvReg, viTlvReg);
}
@Override
final BitSet flags = ByteArray.bytesToBitSet(ByteArray.readBytes(bytes, FLAGS_SIZE));
builder.addAugmentation(Srp1.class, new Srp1Builder().setRemove(flags.get(REMOVE_FLAG)).build());
builder.setOperationId(new SrpIdNumber(bytes.readUnsignedInt()));
- parseTlvs(builder, bytes.slice());
+ final TlvsBuilder tlvsBuilder = new TlvsBuilder();
+ parseTlvs(tlvsBuilder, bytes.slice());
+ builder.setTlvs(tlvsBuilder.build());
return builder.build();
}
import java.util.ArrayList;
import java.util.List;
-
import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderContext;
import org.opendaylight.protocol.pcep.spi.TlvRegistry;
+import org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry;
import org.opendaylight.protocol.pcep.spi.pojo.AbstractPCEPExtensionProviderActivator;
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.lsp.object.Lsp;
new CInitiated00PCInitiateMessageParser(context.getObjectHandlerRegistry())));
final TlvRegistry tlvReg = context.getTlvHandlerRegistry();
+ final VendorInformationTlvRegistry viTlvReg = context.getVendorInformationTlvRegistry();
regs.add(context.registerObjectParser(CInitiated00LspObjectParser.CLASS, CInitiated00LspObjectParser.TYPE,
- new CInitiated00LspObjectParser(tlvReg)));
- regs.add(context.registerObjectSerializer(Lsp.class, new CInitiated00LspObjectParser(tlvReg)));
+ new CInitiated00LspObjectParser(tlvReg, viTlvReg)));
+ regs.add(context.registerObjectSerializer(Lsp.class, new CInitiated00LspObjectParser(tlvReg, viTlvReg)));
regs.add(context.registerObjectParser(CInitiated00SrpObjectParser.CLASS, CInitiated00SrpObjectParser.TYPE,
- new CInitiated00SrpObjectParser(tlvReg)));
- regs.add(context.registerObjectSerializer(Srp.class, new CInitiated00SrpObjectParser(tlvReg)));
+ new CInitiated00SrpObjectParser(tlvReg, viTlvReg)));
+ regs.add(context.registerObjectSerializer(Srp.class, new CInitiated00SrpObjectParser(tlvReg, viTlvReg)));
regs.add(context.registerTlvParser(CInitiated00StatefulCapabilityTlvParser.TYPE, new CInitiated00StatefulCapabilityTlvParser()));
regs.add(context.registerTlvSerializer(Stateful.class, new CInitiated00StatefulCapabilityTlvParser()));
package org.opendaylight.protocol.pcep.ietf.stateful07;
import com.google.common.base.Preconditions;
-
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import java.util.BitSet;
-
+import java.util.List;
import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
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.util.ByteArray;
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.PlspId;
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.vendor.information.tlvs.VendorInformationTlv;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vs.tlv.VsTlv;
/**
protected static final int ADMINISTRATIVE_FLAG_OFFSET = 12;
protected static final int OPERATIONAL_OFFSET = 9;
- public Stateful07LspObjectParser(final TlvRegistry tlvReg) {
- super(tlvReg);
+ public Stateful07LspObjectParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
+ super(tlvReg, viTlvReg);
}
@Override
if (tlvs.getVsTlv() != null) {
serializeTlv(tlvs.getVsTlv(), body);
}
+ serializeVendorInformationTlvs(tlvs.getVendorInformationTlv(), body);
+ }
+
+ @Override
+ protected final void addVendorInformationTlvs(final TlvsBuilder builder, final List<VendorInformationTlv> tlvs) {
+ if (!tlvs.isEmpty()) {
+ builder.setVendorInformationTlv(tlvs);
+ }
}
}
package org.opendaylight.protocol.pcep.ietf.stateful07;
import io.netty.buffer.ByteBuf;
-
import org.opendaylight.protocol.pcep.impl.object.PCEPLspaObjectParser;
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.Tlvs2;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.Tlvs2Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.symbolic.path.name.tlv.SymbolicPathName;
*/
public class Stateful07LspaObjectParser extends PCEPLspaObjectParser {
- public Stateful07LspaObjectParser(final TlvRegistry tlvReg) {
- super(tlvReg);
+ public Stateful07LspaObjectParser(TlvRegistry tlvReg, VendorInformationTlvRegistry viTlvReg) {
+ super(tlvReg, viTlvReg);
}
@Override
package org.opendaylight.protocol.pcep.ietf.stateful07;
import io.netty.buffer.ByteBuf;
-
import org.opendaylight.protocol.pcep.impl.object.PCEPOpenObjectParser;
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.Tlvs1;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.Tlvs1Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.stateful.capability.tlv.Stateful;
*/
public class Stateful07OpenObjectParser extends PCEPOpenObjectParser {
- public Stateful07OpenObjectParser(final TlvRegistry tlvReg) {
- super(tlvReg);
+ public Stateful07OpenObjectParser(TlvRegistry tlvReg, VendorInformationTlvRegistry viTlvReg) {
+ super(tlvReg, viTlvReg);
}
@Override
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
+import java.util.List;
import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
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.SrpIdNumber;
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.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.vendor.information.tlvs.VendorInformationTlv;
/**
* Parser for {@link Srp}
*/
-public class Stateful07SrpObjectParser extends AbstractObjectWithTlvsParser<SrpBuilder> {
+public class Stateful07SrpObjectParser extends AbstractObjectWithTlvsParser<TlvsBuilder> {
public static final int CLASS = 33;
protected static final int MIN_SIZE = FLAGS_SIZE + SRP_ID_SIZE;
- public Stateful07SrpObjectParser(final TlvRegistry tlvReg) {
- super(tlvReg);
+ protected Stateful07SrpObjectParser(TlvRegistry tlvReg, VendorInformationTlvRegistry viTlvReg) {
+ super(tlvReg, viTlvReg);
}
@Override
builder.setProcessingRule(header.isProcessingRule());
bytes.readerIndex(bytes.readerIndex() + FLAGS_SIZE);
builder.setOperationId(new SrpIdNumber(bytes.readUnsignedInt()));
+ final TlvsBuilder tlvsBuilder = new TlvsBuilder();
+ parseTlvs(tlvsBuilder, bytes.slice());
+ builder.setTlvs(tlvsBuilder.build());
return builder.build();
}
@Override
- public void addTlv(final SrpBuilder builder, final Tlv tlv) {
+ public void addTlv(final TlvsBuilder builder, final Tlv tlv) {
if (tlv instanceof SymbolicPathName) {
- builder.setTlvs(new TlvsBuilder().setSymbolicPathName((SymbolicPathName) tlv).build());
+ builder.setSymbolicPathName((SymbolicPathName) tlv);
}
}
serializeTlv(tlvs.getSymbolicPathName(), body);
}
}
+
+ @Override
+ protected final void addVendorInformationTlvs(final TlvsBuilder builder, final List<VendorInformationTlv> tlvs) {
+ if (!tlvs.isEmpty()) {
+ builder.setVendorInformationTlv(tlvs);
+ }
+ }
}
import org.opendaylight.protocol.pcep.spi.ObjectRegistry;
import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderContext;
import org.opendaylight.protocol.pcep.spi.TlvRegistry;
+import org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry;
import org.opendaylight.protocol.pcep.spi.pojo.AbstractPCEPExtensionProviderActivator;
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;
regs.add(context.registerMessageSerializer(Pcerr.class, new Stateful07ErrorMessageParser(objReg)));
final TlvRegistry tlvReg = context.getTlvHandlerRegistry();
+ final VendorInformationTlvRegistry viTlvReg = context.getVendorInformationTlvRegistry();
regs.add(context.registerObjectParser(Stateful07LspObjectParser.CLASS, Stateful07LspObjectParser.TYPE,
- new Stateful07LspObjectParser(tlvReg)));
- regs.add(context.registerObjectSerializer(Lsp.class, new Stateful07LspObjectParser(tlvReg)));
+ new Stateful07LspObjectParser(tlvReg, viTlvReg)));
+ regs.add(context.registerObjectSerializer(Lsp.class, new Stateful07LspObjectParser(tlvReg, viTlvReg)));
regs.add(context.registerObjectParser(Stateful07SrpObjectParser.CLASS, Stateful07SrpObjectParser.TYPE,
- new Stateful07SrpObjectParser(tlvReg)));
- regs.add(context.registerObjectSerializer(Srp.class, new Stateful07SrpObjectParser(tlvReg)));
+ new Stateful07SrpObjectParser(tlvReg, viTlvReg)));
+ regs.add(context.registerObjectSerializer(Srp.class, new Stateful07SrpObjectParser(tlvReg, viTlvReg)));
regs.add(context.registerObjectParser(Stateful07OpenObjectParser.CLASS, Stateful07OpenObjectParser.TYPE,
- new Stateful07OpenObjectParser(tlvReg)));
- regs.add(context.registerObjectSerializer(Open.class, new Stateful07OpenObjectParser(tlvReg)));
+ new Stateful07OpenObjectParser(tlvReg, viTlvReg)));
+ regs.add(context.registerObjectSerializer(Open.class, new Stateful07OpenObjectParser(tlvReg, viTlvReg)));
regs.add(context.registerTlvParser(Stateful07LSPIdentifierIpv4TlvParser.TYPE, new Stateful07LSPIdentifierIpv4TlvParser()));
regs.add(context.registerTlvParser(Stateful07LSPIdentifierIpv6TlvParser.TYPE, new Stateful07LSPIdentifierIpv6TlvParser()));
uses symbolic-path-name-tlv;
uses pcep:vs-tlv;
+
+ uses pcep:vendor-information-tlvs;
}
leaf plsp-id {
container "tlvs" {
uses symbolic-path-name-tlv;
+
+ uses pcep:vendor-information-tlvs;
}
leaf operation-id {
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
+
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import java.io.IOException;
-
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.protocol.pcep.ietf.initiated00.CInitiated00LspObjectParser;
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.ServiceLoaderPCEPExtensionProviderContext;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.Lsp1;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.error.code.tlv.LspErrorCodeBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.object.LspBuilder;
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.ietf.stateful.rev131222.stateful.capability.tlv.Stateful;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.stateful.capability.tlv.StatefulBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.symbolic.path.name.tlv.SymbolicPathName;
private TlvRegistry tlvRegistry;
+ private VendorInformationTlvRegistry viTlvRegistry;
+
@Before
public void setUp() throws Exception {
this.tlvRegistry = ServiceLoaderPCEPExtensionProviderContext.create().getTlvHandlerRegistry();
+ this.viTlvRegistry = ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance().getVendorInformationTlvRegistry();
}
@Test
public void testOpenObjectWithTLV() throws PCEPDeserializerException, IOException {
- final Stateful07OpenObjectParser parser = new Stateful07OpenObjectParser(this.tlvRegistry);
+ final Stateful07OpenObjectParser parser = new Stateful07OpenObjectParser(this.tlvRegistry, this.viTlvRegistry);
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPOpenObject1.bin"));
final OpenBuilder builder = new OpenBuilder();
@Test
public void testLspObjectWithTLV() throws IOException, PCEPDeserializerException {
- final CInitiated00LspObjectParser parser = new CInitiated00LspObjectParser(this.tlvRegistry);
+ final CInitiated00LspObjectParser parser = new CInitiated00LspObjectParser(this.tlvRegistry, this.viTlvRegistry);
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspObject1WithTLV.bin"));
final LspBuilder builder = new LspBuilder();
@Test
public void testLspaObject() throws IOException, PCEPDeserializerException {
- final Stateful07LspaObjectParser parser = new Stateful07LspaObjectParser(this.tlvRegistry);
+ final Stateful07LspaObjectParser parser = new Stateful07LspaObjectParser(this.tlvRegistry, this.viTlvRegistry);
final LspaBuilder builder = new LspaBuilder();
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspaObject3RandVals.bin"));
@Test
public void testSrpObject() throws IOException, PCEPDeserializerException {
- final CInitiated00SrpObjectParser parser = new CInitiated00SrpObjectParser(this.tlvRegistry);
+ final CInitiated00SrpObjectParser parser = new CInitiated00SrpObjectParser(this.tlvRegistry, this.viTlvRegistry);
final ByteBuf result = Unpooled.wrappedBuffer(new byte[] { (byte) 0x21, (byte) 0x10, (byte) 0x00, (byte) 0x0c, 0, 0, 0,
(byte) 0x01, 0, 0, 0, (byte) 0x01 });
builder.setIgnore(false);
builder.setOperationId(new SrpIdNumber(1L));
builder.addAugmentation(Srp1.class, new Srp1Builder().setRemove(true).build());
+ builder.setTlvs(new TlvsBuilder().build());
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
ByteBuf buf = Unpooled.buffer();
srpBuilder.setProcessingRule(false);
srpBuilder.setOperationId(new SrpIdNumber(1L));
srpBuilder.addAugmentation(Srp1.class, new Srp1Builder().setRemove(false).build());
+ srpBuilder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.srp.TlvsBuilder().build());
this.srp = srpBuilder.build();
final LspBuilder lspBuilder = new LspBuilder();
final PcerrMessageBuilder builder = new PcerrMessageBuilder();
builder.setErrors(innerErr);
List<Srps> srps = new ArrayList<>();
- srps.add(new SrpsBuilder().setSrp(new SrpBuilder().setOperationId(new SrpIdNumber(3L)).setIgnore(false).setProcessingRule(false).build()).build());
+ srps.add(new SrpsBuilder().setSrp(new SrpBuilder().setOperationId(new SrpIdNumber(3L)).setIgnore(false).setProcessingRule(false).setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.srp.TlvsBuilder().build()).build()).build());
builder.setErrorType(new StatefulCaseBuilder().setStateful(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.pcerr.pcerr.message.error.type.stateful._case.StatefulBuilder().setSrps(srps).build()).build());
assertEquals(new PcerrBuilder().setPcerrMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
import org.opendaylight.protocol.pcep.spi.ObjectRegistry;
import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderContext;
import org.opendaylight.protocol.pcep.spi.TlvRegistry;
+import org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry;
import org.opendaylight.protocol.pcep.spi.pojo.AbstractPCEPExtensionProviderActivator;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Close;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Keepalive;
private void registerObjectParsers(final List<AutoCloseable> regs, final PCEPExtensionProviderContext context) {
final TlvRegistry tlvReg = context.getTlvHandlerRegistry();
- final PCEPOpenObjectParser openParser = new PCEPOpenObjectParser(tlvReg);
+ final VendorInformationTlvRegistry viTlvReg = context.getVendorInformationTlvRegistry();
+ final PCEPOpenObjectParser openParser = new PCEPOpenObjectParser(tlvReg, viTlvReg);
regs.add(context.registerObjectParser(PCEPOpenObjectParser.CLASS, PCEPOpenObjectParser.TYPE, openParser));
regs.add(context.registerObjectSerializer(Open.class, openParser));
- final PCEPRequestParameterObjectParser rpParser = new PCEPRequestParameterObjectParser(tlvReg);
+ final PCEPRequestParameterObjectParser rpParser = new PCEPRequestParameterObjectParser(tlvReg, viTlvReg);
regs.add(context.registerObjectParser(PCEPRequestParameterObjectParser.CLASS, PCEPRequestParameterObjectParser.TYPE, rpParser));
regs.add(context.registerObjectSerializer(Rp.class, rpParser));
- final PCEPNoPathObjectParser noPathParser = new PCEPNoPathObjectParser(tlvReg);
+ final PCEPNoPathObjectParser noPathParser = new PCEPNoPathObjectParser(tlvReg, viTlvReg);
regs.add(context.registerObjectParser(PCEPNoPathObjectParser.CLASS, PCEPNoPathObjectParser.TYPE, noPathParser));
regs.add(context.registerObjectSerializer(NoPath.class, noPathParser));
- final PCEPEndPointsIpv4ObjectParser endpoints4Parser = new PCEPEndPointsIpv4ObjectParser(tlvReg);
+ final PCEPEndPointsIpv4ObjectParser endpoints4Parser = new PCEPEndPointsIpv4ObjectParser();
regs.add(context.registerObjectParser(PCEPEndPointsIpv4ObjectParser.CLASS, PCEPEndPointsIpv4ObjectParser.TYPE, endpoints4Parser));
regs.add(context.registerObjectParser(PCEPEndPointsIpv6ObjectParser.CLASS, PCEPEndPointsIpv6ObjectParser.TYPE,
- new PCEPEndPointsIpv4ObjectParser(tlvReg)));
+ new PCEPEndPointsIpv4ObjectParser()));
regs.add(context.registerObjectSerializer(EndpointsObj.class, endpoints4Parser));
- final PCEPBandwidthObjectParser bwParser = new PCEPBandwidthObjectParser(tlvReg);
+ final PCEPBandwidthObjectParser bwParser = new PCEPBandwidthObjectParser();
regs.add(context.registerObjectParser(PCEPBandwidthObjectParser.CLASS, PCEPBandwidthObjectParser.TYPE, bwParser));
regs.add(context.registerObjectParser(PCEPExistingBandwidthObjectParser.CLASS, PCEPExistingBandwidthObjectParser.TYPE,
- new PCEPExistingBandwidthObjectParser(tlvReg)));
+ new PCEPExistingBandwidthObjectParser()));
regs.add(context.registerObjectSerializer(Bandwidth.class, bwParser));
- final PCEPMetricObjectParser metricParser = new PCEPMetricObjectParser(tlvReg);
+ final PCEPMetricObjectParser metricParser = new PCEPMetricObjectParser();
regs.add(context.registerObjectParser(PCEPMetricObjectParser.CLASS, PCEPMetricObjectParser.TYPE, metricParser));
regs.add(context.registerObjectSerializer(Metric.class, metricParser));
regs.add(context.registerObjectParser(PCEPReportedRouteObjectParser.CLASS, PCEPReportedRouteObjectParser.TYPE, rroParser));
regs.add(context.registerObjectSerializer(Rro.class, rroParser));
- final PCEPLspaObjectParser lspaParser = new PCEPLspaObjectParser(tlvReg);
+ final PCEPLspaObjectParser lspaParser = new PCEPLspaObjectParser(tlvReg, viTlvReg);
regs.add(context.registerObjectParser(PCEPLspaObjectParser.CLASS, PCEPLspaObjectParser.TYPE, lspaParser));
regs.add(context.registerObjectSerializer(Lspa.class, lspaParser));
regs.add(context.registerObjectParser(PCEPIncludeRouteObjectParser.CLASS, PCEPIncludeRouteObjectParser.TYPE, iroParser));
regs.add(context.registerObjectSerializer(Iro.class, iroParser));
- final PCEPSvecObjectParser svecParser = new PCEPSvecObjectParser(tlvReg);
+ final PCEPSvecObjectParser svecParser = new PCEPSvecObjectParser();
regs.add(context.registerObjectParser(PCEPSvecObjectParser.CLASS, PCEPSvecObjectParser.TYPE, svecParser));
regs.add(context.registerObjectSerializer(Svec.class, svecParser));
- final PCEPNotificationObjectParser notParser = new PCEPNotificationObjectParser(tlvReg);
+ final PCEPNotificationObjectParser notParser = new PCEPNotificationObjectParser(tlvReg, viTlvReg);
regs.add(context.registerObjectParser(PCEPNotificationObjectParser.CLASS, PCEPNotificationObjectParser.TYPE, notParser));
regs.add(context.registerObjectSerializer(CNotification.class, notParser));
- final PCEPErrorObjectParser errParser = new PCEPErrorObjectParser(tlvReg);
+ final PCEPErrorObjectParser errParser = new PCEPErrorObjectParser(tlvReg, viTlvReg);
regs.add(context.registerObjectParser(PCEPErrorObjectParser.CLASS, PCEPErrorObjectParser.TYPE, errParser));
regs.add(context.registerObjectSerializer(ErrorObject.class, errParser));
- final PCEPLoadBalancingObjectParser lbParser = new PCEPLoadBalancingObjectParser(tlvReg);
+ final PCEPLoadBalancingObjectParser lbParser = new PCEPLoadBalancingObjectParser();
regs.add(context.registerObjectParser(PCEPLoadBalancingObjectParser.CLASS, PCEPLoadBalancingObjectParser.TYPE, lbParser));
regs.add(context.registerObjectSerializer(LoadBalancing.class, lbParser));
- final PCEPCloseObjectParser closeParser = new PCEPCloseObjectParser(tlvReg);
+ final PCEPCloseObjectParser closeParser = new PCEPCloseObjectParser(tlvReg, viTlvReg);
regs.add(context.registerObjectParser(PCEPCloseObjectParser.CLASS, PCEPCloseObjectParser.TYPE, closeParser));
regs.add(context.registerObjectSerializer(CClose.class, closeParser));
regs.add(context.registerObjectParser(PCEPExcludeRouteObjectParser.CLASS, PCEPExcludeRouteObjectParser.TYPE, xroParser));
regs.add(context.registerObjectSerializer(Xro.class, xroParser));
- final PCEPObjectiveFunctionObjectParser objectiveParser = new PCEPObjectiveFunctionObjectParser(tlvReg);
+ final PCEPObjectiveFunctionObjectParser objectiveParser = new PCEPObjectiveFunctionObjectParser(tlvReg, viTlvReg);
regs.add(context.registerObjectParser(PCEPObjectiveFunctionObjectParser.CLASS, PCEPObjectiveFunctionObjectParser.TYPE, objectiveParser));
regs.add(context.registerObjectSerializer(Of.class, objectiveParser));
- final PCEPClassTypeObjectParser ctParser = new PCEPClassTypeObjectParser(tlvReg);
+ final PCEPClassTypeObjectParser ctParser = new PCEPClassTypeObjectParser();
regs.add(context.registerObjectParser(PCEPClassTypeObjectParser.CLASS, PCEPClassTypeObjectParser.TYPE, ctParser));
regs.add(context.registerObjectSerializer(ClassType.class, ctParser));
- final PCEPGlobalConstraintsObjectParser gcParser = new PCEPGlobalConstraintsObjectParser(tlvReg);
+ final PCEPGlobalConstraintsObjectParser gcParser = new PCEPGlobalConstraintsObjectParser(tlvReg, viTlvReg);
regs.add(context.registerObjectParser(PCEPGlobalConstraintsObjectParser.CLASS, PCEPGlobalConstraintsObjectParser.TYPE, gcParser));
regs.add(context.registerObjectSerializer(Gc.class, gcParser));
}
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
+import org.opendaylight.protocol.pcep.spi.ObjectParser;
+import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.spi.TlvRegistry;
import org.opendaylight.protocol.util.ByteArray;
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.bandwidth.object.Bandwidth;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.bandwidth.object.BandwidthBuilder;
-abstract class AbstractBandwidthParser extends AbstractObjectWithTlvsParser<BandwidthBuilder> {
+abstract class AbstractBandwidthParser implements ObjectParser, ObjectSerializer {
private static final int BANDWIDTH_F_LENGTH = 4;
- AbstractBandwidthParser(final TlvRegistry tlvReg) {
- super(tlvReg);
- }
-
@Override
public Bandwidth parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
package org.opendaylight.protocol.pcep.impl.object;
import io.netty.buffer.ByteBuf;
-
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
-import org.opendaylight.protocol.pcep.spi.TlvRegistry;
/**
* Parser for Bandwidth
public static final int TYPE = 1;
- public PCEPBandwidthObjectParser(final TlvRegistry tlvReg) {
- super(tlvReg);
- }
-
@Override
protected void formatBandwidth(final Boolean processed, final Boolean ignored, final ByteBuf body, final ByteBuf buffer) {
ObjectUtil.formatSubobject(TYPE, CLASS, processed, ignored, body, buffer);
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
+import org.opendaylight.protocol.pcep.spi.ObjectParser;
+import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.PCEPErrors;
-import org.opendaylight.protocol.pcep.spi.TlvRegistry;
import org.opendaylight.protocol.pcep.spi.UnknownObject;
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;
/**
* Parser for {@link ClassType}
*/
-public class PCEPClassTypeObjectParser extends AbstractObjectWithTlvsParser<ClassTypeBuilder> {
+public class PCEPClassTypeObjectParser implements ObjectParser, ObjectSerializer {
+
private static final Logger LOG = LoggerFactory.getLogger(PCEPClassTypeObjectParser.class);
public static final int CLASS = 22;
*/
private static final int SIZE = (RESERVED + CT_F_LENGTH) / Byte.SIZE;
- public PCEPClassTypeObjectParser(final TlvRegistry tlvReg) {
- super(tlvReg);
- }
-
@Override
public Object parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
import com.google.common.primitives.UnsignedBytes;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
+import java.util.List;
import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
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.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.close.object.CClose;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.object.CCloseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.object.c.close.Tlvs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.object.c.close.TlvsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.tlvs.VendorInformationTlv;
/**
* Parser for {@link org.opendaylight.protocol.pcep.object.PCEPCloseObject PCEPCloseObject}
*/
-public class PCEPCloseObjectParser extends AbstractObjectWithTlvsParser<CCloseBuilder> {
+public class PCEPCloseObjectParser extends AbstractObjectWithTlvsParser<TlvsBuilder> {
public static final int CLASS = 15;
private static final int RESERVED = 2;
private static final int FLAGS_F_LENGTH = 1;
- public PCEPCloseObjectParser(final TlvRegistry tlvReg) {
- super(tlvReg);
+ public PCEPCloseObjectParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
+ super(tlvReg, viTlvReg);
}
+
@Override
public CClose parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
builder.setProcessingRule(header.isProcessingRule());
bytes.readerIndex(bytes.readerIndex() + FLAGS_F_LENGTH + RESERVED);
builder.setReason((short) UnsignedBytes.toInt(bytes.readByte()));
- parseTlvs(builder, bytes.slice());
+ final TlvsBuilder tlvsBuilder = new TlvsBuilder();
+ parseTlvs(tlvsBuilder, bytes.slice());
+ builder.setTlvs(tlvsBuilder.build());
return builder.build();
}
}
public void serializeTlvs(final Tlvs tlvs, final ByteBuf body) {
- return;
+ if (tlvs == null) {
+ return;
+ }
+ serializeVendorInformationTlvs(tlvs.getVendorInformationTlv(), body);
+ }
+
+
+ @Override
+ protected final void addVendorInformationTlvs(final TlvsBuilder builder, final List<VendorInformationTlv> tlvs) {
+ if (!tlvs.isEmpty()) {
+ builder.setVendorInformationTlv(tlvs);
+ }
}
}
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
+import org.opendaylight.protocol.pcep.spi.ObjectParser;
+import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.PCEPErrors;
-import org.opendaylight.protocol.pcep.spi.TlvRegistry;
import org.opendaylight.protocol.pcep.spi.UnknownObject;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.protocol.util.Ipv4Util;
/**
* Parser for IPv4 {@link EndpointsObj}
*/
-public class PCEPEndPointsIpv4ObjectParser extends AbstractObjectWithTlvsParser<EndpointsObjBuilder> {
+public class PCEPEndPointsIpv4ObjectParser implements ObjectParser, ObjectSerializer {
private static final Logger LOG = LoggerFactory.getLogger(PCEPEndPointsIpv4ObjectParser.class);
public static final int TYPE = 1;
- public PCEPEndPointsIpv4ObjectParser(final TlvRegistry tlvReg) {
- super(tlvReg);
- }
-
@Override
public Object parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
+import org.opendaylight.protocol.pcep.spi.ObjectParser;
+import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.PCEPErrors;
-import org.opendaylight.protocol.pcep.spi.TlvRegistry;
import org.opendaylight.protocol.pcep.spi.UnknownObject;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.protocol.util.Ipv6Util;
/**
* Parser for IPv6 {@link EndpointsObj}
*/
-public class PCEPEndPointsIpv6ObjectParser extends AbstractObjectWithTlvsParser<EndpointsObjBuilder> {
+public class PCEPEndPointsIpv6ObjectParser implements ObjectParser, ObjectSerializer {
private static final Logger LOG = LoggerFactory.getLogger(PCEPEndPointsIpv6ObjectParser.class);
public static final int TYPE = 2;
- public PCEPEndPointsIpv6ObjectParser(final TlvRegistry tlvReg) {
- super(tlvReg);
- }
-
@Override
public Object parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
import com.google.common.primitives.UnsignedBytes;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
+import java.util.List;
import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
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.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.pcep.error.object.error.object.Tlvs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.error.object.TlvsBuilder;
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.vendor.information.tlvs.VendorInformationTlv;
/**
* Parser for {@link ErrorObject}
private static final int RESERVED = 1;
- public PCEPErrorObjectParser(final TlvRegistry tlvReg) {
- super(tlvReg);
+ public PCEPErrorObjectParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
+ super(tlvReg, viTlvReg);
}
@Override
public void serializeTlvs(final Tlvs tlvs, final ByteBuf body) {
if (tlvs == null) {
return;
- } else if (tlvs.getReqMissing() != null) {
+ }
+ if (tlvs.getReqMissing() != null) {
serializeTlv(tlvs.getReqMissing(), body);
}
+ serializeVendorInformationTlvs(tlvs.getVendorInformationTlv(), body);
+ }
+
+ @Override
+ protected final void addVendorInformationTlvs(final ErrorObjectBuilder builder, final List<VendorInformationTlv> tlvs) {
+ if (!tlvs.isEmpty()) {
+ builder.setTlvs(new TlvsBuilder(builder.getTlvs()).setVendorInformationTlv(tlvs).build());
+ }
}
}
package org.opendaylight.protocol.pcep.impl.object;
import io.netty.buffer.ByteBuf;
-
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
-import org.opendaylight.protocol.pcep.spi.TlvRegistry;
/**
* Parser for Bandwidth
public static final int TYPE = 2;
- public PCEPExistingBandwidthObjectParser(final TlvRegistry tlvReg) {
- super(tlvReg);
- }
-
@Override
protected void formatBandwidth(final Boolean processed, final Boolean ignored, final ByteBuf body, final ByteBuf buffer) {
ObjectUtil.formatSubobject(TYPE, CLASS, processed, ignored, body, buffer);
import com.google.common.primitives.UnsignedBytes;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
+import java.util.List;
import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
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.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.gc.object.Gc;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.gc.object.GcBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.gc.object.gc.Tlvs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.gc.object.gc.TlvsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.tlvs.VendorInformationTlv;
/**
* Parser for {@link Gc}
*/
-public class PCEPGlobalConstraintsObjectParser extends AbstractObjectWithTlvsParser<GcBuilder> {
+public class PCEPGlobalConstraintsObjectParser extends AbstractObjectWithTlvsParser<TlvsBuilder> {
public static final int CLASS = 24;
public static final int TYPE = 1;
- public PCEPGlobalConstraintsObjectParser(final TlvRegistry tlvReg) {
- super(tlvReg);
+ public PCEPGlobalConstraintsObjectParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
+ super(tlvReg, viTlvReg);
}
@Override
builder.setMaxUtilization((short) UnsignedBytes.toInt(bytes.readByte()));
builder.setMinUtilization((short) UnsignedBytes.toInt(bytes.readByte()));
builder.setOverBookingFactor((short) UnsignedBytes.toInt(bytes.readByte()));
+ final TlvsBuilder tlvsBuilder = new TlvsBuilder();
+ parseTlvs(tlvsBuilder, bytes.slice());
+ builder.setTlvs(tlvsBuilder.build());
return builder.build();
}
writeUnsignedByte(specObj.getMaxUtilization(), body);
writeUnsignedByte(specObj.getMinUtilization(), body);
writeUnsignedByte(specObj.getOverBookingFactor(), body);
+ serializeTlvs(specObj.getTlvs(), body);
ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
+
+ public void serializeTlvs(final Tlvs tlvs, final ByteBuf body) {
+ if (tlvs == null) {
+ return;
+ }
+ serializeVendorInformationTlvs(tlvs.getVendorInformationTlv(), body);
+ }
+
+ @Override
+ protected final void addVendorInformationTlvs(final TlvsBuilder builder, final List<VendorInformationTlv> tlvs) {
+ if (!tlvs.isEmpty()) {
+ builder.setVendorInformationTlv(tlvs);
+ }
+ }
}
import com.google.common.primitives.UnsignedBytes;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
+import org.opendaylight.protocol.pcep.spi.ObjectParser;
+import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.spi.TlvRegistry;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
/**
* Parser for {@link LoadBalancing}
*/
-public class PCEPLoadBalancingObjectParser extends AbstractObjectWithTlvsParser<LoadBalancingBuilder> {
+public class PCEPLoadBalancingObjectParser implements ObjectParser, ObjectSerializer {
public static final int CLASS = 14;
private static final int SIZE = 8;
- public PCEPLoadBalancingObjectParser(final TlvRegistry tlvReg) {
- super(tlvReg);
- }
-
@Override
public LoadBalancing parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.util.BitSet;
+import java.util.List;
import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
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.util.ByteArray;
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.lspa.object.LspaBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lspa.object.lspa.Tlvs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lspa.object.lspa.TlvsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.tlvs.VendorInformationTlv;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.AttributeFilter;
/**
private static final int RESERVED = 1;
- public PCEPLspaObjectParser(final TlvRegistry tlvReg) {
- super(tlvReg);
+ public PCEPLspaObjectParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
+ super(tlvReg, viTlvReg);
}
@Override
}
public void serializeTlvs(final Tlvs tlvs, final ByteBuf body) {
- return;
+ if (tlvs == null) {
+ return;
+ }
+ serializeVendorInformationTlvs(tlvs.getVendorInformationTlv(), body);
}
private void writeAttributeFilter(final AttributeFilter attributeFilter, final ByteBuf body) {
writeUnsignedInt(attributeFilter != null ? attributeFilter.getValue() : null, body);
}
+
+ @Override
+ protected final void addVendorInformationTlvs(final TlvsBuilder builder, final List<VendorInformationTlv> tlvs) {
+ if (!tlvs.isEmpty()) {
+ builder.setVendorInformationTlv(tlvs);
+ }
+ }
}
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.util.BitSet;
-import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
+import org.opendaylight.protocol.pcep.spi.ObjectParser;
+import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.spi.TlvRegistry;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
/**
* Parser for {@link Metric}
*/
-public class PCEPMetricObjectParser extends AbstractObjectWithTlvsParser<MetricBuilder> {
+public class PCEPMetricObjectParser implements ObjectParser, ObjectSerializer {
public static final int CLASS = 6;
private static final int SIZE = 4 + METRIC_VALUE_F_LENGTH;
- public PCEPMetricObjectParser(final TlvRegistry tlvReg) {
- super(tlvReg);
- }
-
@Override
public Metric parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.util.BitSet;
+import java.util.List;
import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
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.util.ByteArray;
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.pcrep.message.pcrep.message.replies.result.failure._case.no.path.Tlvs;
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.TlvsBuilder;
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;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.tlvs.VendorInformationTlv;
/**
* Parser for {@link NoPath}
*/
-public class PCEPNoPathObjectParser extends AbstractObjectWithTlvsParser<NoPathBuilder> {
+public class PCEPNoPathObjectParser extends AbstractObjectWithTlvsParser<TlvsBuilder> {
public static final int CLASS = 3;
*/
private static final int C_FLAG_OFFSET = 0;
- public PCEPNoPathObjectParser(final TlvRegistry tlvReg) {
- super(tlvReg);
+ public PCEPNoPathObjectParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
+ super(tlvReg, viTlvReg);
}
@Override
final BitSet flags = ByteArray.bytesToBitSet(flagsByte);
builder.setUnsatisfiedConstraints(flags.get(C_FLAG_OFFSET));
bytes.readerIndex(bytes.readerIndex() + RESERVED_F_LENGTH);
- parseTlvs(builder, bytes.slice());
+ final TlvsBuilder tlvsBuilder = new TlvsBuilder();
+ parseTlvs(tlvsBuilder, bytes.slice());
+ builder.setTlvs(tlvsBuilder.build());
return builder.build();
}
@Override
- public void addTlv(final NoPathBuilder builder, final Tlv tlv) {
+ public void addTlv(final TlvsBuilder builder, final Tlv tlv) {
if (tlv instanceof NoPathVector) {
- builder.setTlvs(new TlvsBuilder().setNoPathVector((NoPathVector) tlv).build());
+ builder.setNoPathVector((NoPathVector) tlv);
}
}
if (tlvs.getNoPathVector() != null) {
serializeTlv(tlvs.getNoPathVector(), body);
}
+ serializeVendorInformationTlvs(tlvs.getVendorInformationTlv(), body);
+ }
+
+ @Override
+ protected final void addVendorInformationTlvs(final TlvsBuilder builder, final List<VendorInformationTlv> tlvs) {
+ if(!tlvs.isEmpty()) {
+ builder.setVendorInformationTlv(tlvs);
+ }
}
}
import com.google.common.primitives.UnsignedBytes;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
+import java.util.List;
import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
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.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.notification.object.c.notification.Tlvs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.notification.object.c.notification.TlvsBuilder;
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.vendor.information.tlvs.VendorInformationTlv;
/**
* Parser for {@link CNotification}
*/
private static final int NT_F_OFFSET = 2;
- public PCEPNotificationObjectParser(final TlvRegistry tlvReg) {
- super(tlvReg);
+ public PCEPNotificationObjectParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
+ super(tlvReg, viTlvReg);
}
@Override
if (tlvs.getOverloadDuration() != null) {
serializeTlv(tlvs.getOverloadDuration(), body);
}
+ serializeVendorInformationTlvs(tlvs.getVendorInformationTlv(), body);
+ }
+
+ @Override
+ protected final void addVendorInformationTlvs(final CNotificationBuilder builder, final List<VendorInformationTlv> tlvs) {
+ if (!tlvs.isEmpty()) {
+ builder.setTlvs(new TlvsBuilder(builder.getTlvs()).setVendorInformationTlv(tlvs).build());
+ }
}
}
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
+import java.util.List;
import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
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.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.OfId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.object.Of;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.object.OfBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.object.of.Tlvs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.object.of.TlvsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.tlvs.VendorInformationTlv;
/**
* Parser for {@link Of}
*/
-public class PCEPObjectiveFunctionObjectParser extends AbstractObjectWithTlvsParser<OfBuilder> {
+public class PCEPObjectiveFunctionObjectParser extends AbstractObjectWithTlvsParser<TlvsBuilder> {
public static final int CLASS = 21;
private static final int RESERVED = 2;
- public PCEPObjectiveFunctionObjectParser(final TlvRegistry tlvReg) {
- super(tlvReg);
+ public PCEPObjectiveFunctionObjectParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
+ super(tlvReg, viTlvReg);
}
@Override
builder.setIgnore(header.isIgnore());
builder.setProcessingRule(header.isProcessingRule());
builder.setCode(new OfId(bytes.readUnsignedShort()));
+ bytes.readBytes(RESERVED);
+ final TlvsBuilder tlvsBuilder = new TlvsBuilder();
+ parseTlvs(tlvsBuilder, bytes.slice());
+ builder.setTlvs(tlvsBuilder.build());
return builder.build();
}
Preconditions.checkArgument(specObj.getCode() != null, "Code is mandatory");
writeUnsignedShort(specObj.getCode().getValue(), body);
body.writeZero(RESERVED);
+ serializeTlvs(specObj.getTlvs(), body);
ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
+
+ public void serializeTlvs(final Tlvs tlvs, final ByteBuf body) {
+ if (tlvs == null) {
+ return;
+ }
+ serializeVendorInformationTlvs(tlvs.getVendorInformationTlv(), body);
+ }
+
+ @Override
+ protected final void addVendorInformationTlvs(final TlvsBuilder builder, final List<VendorInformationTlv> tlvs) {
+ if (!tlvs.isEmpty()) {
+ builder.setVendorInformationTlv(tlvs);
+ }
+ }
}
import com.google.common.primitives.UnsignedBytes;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
+import java.util.List;
import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.PCEPErrors;
import org.opendaylight.protocol.pcep.spi.TlvRegistry;
import org.opendaylight.protocol.pcep.spi.UnknownObject;
+import org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry;
import org.opendaylight.protocol.util.ByteArray;
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.open.object.OpenBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.Tlvs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.tlvs.VendorInformationTlv;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final int PCEP_VERSION = 1;
- public PCEPOpenObjectParser(final TlvRegistry tlvReg) {
- super(tlvReg);
+ public PCEPOpenObjectParser(TlvRegistry tlvReg, VendorInformationTlvRegistry viTlvReg) {
+ super(tlvReg, viTlvReg);
}
@Override
if (tlvs.getOfList() != null) {
serializeTlv(tlvs.getOfList(), body);
}
+ serializeVendorInformationTlvs(tlvs.getVendorInformationTlv(), body);
+ }
+
+ @Override
+ protected final void addVendorInformationTlvs(final TlvsBuilder builder, final List<VendorInformationTlv> tlvs) {
+ if (!tlvs.isEmpty()) {
+ builder.setVendorInformationTlv(tlvs);
+ }
}
}
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.util.BitSet;
+import java.util.List;
import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
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.util.ByteArray;
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.rp.object.RpBuilder;
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;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.tlvs.VendorInformationTlv;
/**
* Parser for {@link Rp}
*/
-public class PCEPRequestParameterObjectParser extends AbstractObjectWithTlvsParser<RpBuilder> {
+public class PCEPRequestParameterObjectParser extends AbstractObjectWithTlvsParser<TlvsBuilder> {
public static final int CLASS = 2;
private static final int E_FLAG_OFFSET = 20;
- public PCEPRequestParameterObjectParser(final TlvRegistry tlvReg) {
- super(tlvReg);
+ public PCEPRequestParameterObjectParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
+ super(tlvReg, viTlvReg);
}
@Override
builder.setReoptimization(flags.get(R_FLAG_OFFSET));
builder.setRequestId(new RequestId(bytes.readUnsignedInt()));
- parseTlvs(builder, bytes.slice());
+ final TlvsBuilder tlvsBuilder = new TlvsBuilder();
+ parseTlvs(tlvsBuilder, bytes.slice());
+ builder.setTlvs(tlvsBuilder.build());
return builder.build();
}
@Override
- public void addTlv(final RpBuilder builder, final Tlv tlv) {
+ public void addTlv(final TlvsBuilder builder, final Tlv tlv) {
if (tlv instanceof Order) {
- builder.setTlvs(new TlvsBuilder().setOrder((Order) tlv).build());
+ builder.setOrder((Order) tlv);
}
}
} else if (tlvs.getOrder() != null) {
serializeTlv(tlvs.getOrder(), body);
}
+ serializeVendorInformationTlvs(tlvs.getVendorInformationTlv(), body);
+ }
+
+ @Override
+ protected final void addVendorInformationTlvs(final TlvsBuilder builder, final List<VendorInformationTlv> tlvs) {
+ if (!tlvs.isEmpty()) {
+ builder.setVendorInformationTlv(tlvs);
+ }
}
}
import io.netty.buffer.Unpooled;
import java.util.BitSet;
import java.util.List;
-import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
+import org.opendaylight.protocol.pcep.spi.ObjectParser;
+import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.spi.TlvRegistry;
import org.opendaylight.protocol.util.ByteArray;
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;
/**
* Parser for {@link Svec}
*/
-public class PCEPSvecObjectParser extends AbstractObjectWithTlvsParser<SvecBuilder> {
+public class PCEPSvecObjectParser implements ObjectParser, ObjectSerializer {
public static final int CLASS = 11;
*/
private static final int MIN_SIZE = FLAGS_F_LENGTH + FLAGS_F_OFFSET;
- public PCEPSvecObjectParser(final TlvRegistry tlvReg) {
- super(tlvReg);
- }
-
@Override
public Svec parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
--- /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.impl.tlv;
+
+import static org.opendaylight.protocol.pcep.spi.VendorInformationUtil.VENDOR_INFORMATION_TLV_TYPE;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
+
+import com.google.common.base.Preconditions;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+
+import org.opendaylight.protocol.pcep.spi.EnterpriseSpecificInformationParser;
+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.types.rev131005.Tlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.EnterpriseSpecificInformation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.tlvs.VendorInformationTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.tlvs.VendorInformationTlvBuilder;
+
+public abstract class AbstractVendorInformationTlvParser implements TlvSerializer, TlvParser, EnterpriseSpecificInformationParser {
+
+ @Override
+ public final void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
+ Preconditions.checkArgument(tlv instanceof VendorInformationTlv, "Vendor Specific Tlv is mandatory.");
+ final VendorInformationTlv viTlv = (VendorInformationTlv) tlv;
+ final ByteBuf body = Unpooled.buffer();
+ writeUnsignedInt(getEnterpriseNumber().getValue(), body);
+ serializeEnterpriseSpecificInformation(viTlv.getEnterpriseSpecificInformation(), body);
+ TlvUtil.formatTlv(VENDOR_INFORMATION_TLV_TYPE, body, buffer);
+ }
+
+ @Override
+ public final VendorInformationTlv parseTlv(final ByteBuf buffer) throws PCEPDeserializerException {
+ if (buffer == null) {
+ return null;
+ }
+ final VendorInformationTlvBuilder viTlvBuider = new VendorInformationTlvBuilder();
+ viTlvBuider.setEnterpriseNumber(getEnterpriseNumber());
+ if (buffer.isReadable()) {
+ final EnterpriseSpecificInformation esInformation = parseEnterpriseSpecificInformation(buffer.slice());
+ if (esInformation != null) {
+ viTlvBuider.setEnterpriseSpecificInformation(esInformation);
+ }
+ }
+ return viTlvBuider.build();
+ }
+}
import java.util.List;
import org.junit.Before;
import org.junit.Test;
+import org.opendaylight.protocol.pcep.impl.TestVendorInformationTlvParser.TestEnterpriseSpecificInformation;
import org.opendaylight.protocol.pcep.impl.object.PCEPBandwidthObjectParser;
import org.opendaylight.protocol.pcep.impl.object.PCEPClassTypeObjectParser;
import org.opendaylight.protocol.pcep.impl.object.PCEPCloseObjectParser;
import org.opendaylight.protocol.pcep.spi.PCEPErrors;
import org.opendaylight.protocol.pcep.spi.TlvRegistry;
import org.opendaylight.protocol.pcep.spi.UnknownObject;
+import org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry;
import org.opendaylight.protocol.pcep.spi.pojo.SimplePCEPExtensionProviderContext;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.protocol.util.Ipv4Util;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ClassType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.req.missing.tlv.ReqMissingBuilder;
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.svec.object.SvecBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.tlvs.VendorInformationTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.tlvs.VendorInformationTlvBuilder;
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.ExcludeRouteSubobjects.Attribute;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.subobject.type.AsNumberCaseBuilder;
private TlvRegistry tlvRegistry;
+ private VendorInformationTlvRegistry viTlvRegistry;
+
private SimplePCEPExtensionProviderContext ctx;
private Activator act;
+ private TestVendorInformationActivator viAct;
@Before
public void setUp() {
this.ctx = new SimplePCEPExtensionProviderContext();
this.act = new Activator();
+ this.viAct = new TestVendorInformationActivator();
this.act.start(this.ctx);
+ this.viAct.start(this.ctx);
this.tlvRegistry = this.ctx.getTlvHandlerRegistry();
+ this.viTlvRegistry = this.ctx.getVendorInformationTlvRegistry();
}
@Test
public void testOpenObjectWOTLV() throws PCEPDeserializerException, IOException {
- final PCEPOpenObjectParser parser = new PCEPOpenObjectParser(this.tlvRegistry);
+ final PCEPOpenObjectParser parser = new PCEPOpenObjectParser(this.tlvRegistry, this.viTlvRegistry);
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPOpenObject1.bin"));
final OpenBuilder builder = new OpenBuilder();
@Test
public void testCloseObject() throws IOException, PCEPDeserializerException {
- final PCEPCloseObjectParser parser = new PCEPCloseObjectParser(this.tlvRegistry);
+ final PCEPCloseObjectParser parser = new PCEPCloseObjectParser(this.tlvRegistry, this.viTlvRegistry);
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPCloseObject1.bin"));
final CCloseBuilder builder = new CCloseBuilder();
builder.setProcessingRule(false);
builder.setIgnore(false);
builder.setReason((short) 5);
+ builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.object.c.close.TlvsBuilder().build());
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
ByteBuf buf = Unpooled.buffer();
@Test
public void testLoadBalancingObject() throws IOException, PCEPDeserializerException {
- final PCEPLoadBalancingObjectParser parser = new PCEPLoadBalancingObjectParser(this.tlvRegistry);
+ final PCEPLoadBalancingObjectParser parser = new PCEPLoadBalancingObjectParser();
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLoadBalancingObject1.bin"));
final LoadBalancingBuilder builder = new LoadBalancingBuilder();
@Test
public void testBandwidthObject() throws IOException, PCEPDeserializerException {
- final PCEPBandwidthObjectParser parser = new PCEPBandwidthObjectParser(this.tlvRegistry);
+ final PCEPBandwidthObjectParser parser = new PCEPBandwidthObjectParser();
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPBandwidthObject1LowerBounds.bin"));
final BandwidthBuilder builder = new BandwidthBuilder();
@Test
public void testExistingBandwidthObject() throws IOException, PCEPDeserializerException {
- final PCEPExistingBandwidthObjectParser parser = new PCEPExistingBandwidthObjectParser(this.tlvRegistry);
+ final PCEPExistingBandwidthObjectParser parser = new PCEPExistingBandwidthObjectParser();
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPBandwidthObject2UpperBounds.bin"));
final BandwidthBuilder builder = new BandwidthBuilder();
final byte[] srcIPBytes = { (byte) 0xA2, (byte) 0xF5, (byte) 0x11, (byte) 0x0E };
final byte[] destIPBytes = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
- final PCEPEndPointsIpv4ObjectParser parser = new PCEPEndPointsIpv4ObjectParser(this.tlvRegistry);
+ final PCEPEndPointsIpv4ObjectParser parser = new PCEPEndPointsIpv4ObjectParser();
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPEndPointsObject1IPv4.bin"));
final EndpointsObjBuilder builder = new EndpointsObjBuilder();
final byte[] srcIPBytes = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
- final PCEPEndPointsIpv6ObjectParser parser = new PCEPEndPointsIpv6ObjectParser(this.tlvRegistry);
+ final PCEPEndPointsIpv6ObjectParser parser = new PCEPEndPointsIpv6ObjectParser();
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPEndPointsObject2IPv6.bin"));
final EndpointsObjBuilder builder = new EndpointsObjBuilder();
@Test
public void testErrorObjectWithTlv() throws PCEPDeserializerException, IOException {
- final PCEPErrorObjectParser parser = new PCEPErrorObjectParser(this.tlvRegistry);
+ final PCEPErrorObjectParser parser = new PCEPErrorObjectParser(this.tlvRegistry, this.viTlvRegistry);
ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPErrorObject1.bin"));
final ErrorObjectBuilder builder = new ErrorObjectBuilder();
@Test
public void testLspaObject() throws IOException, PCEPDeserializerException {
- final PCEPLspaObjectParser parser = new PCEPLspaObjectParser(this.tlvRegistry);
+ final PCEPLspaObjectParser parser = new PCEPLspaObjectParser(this.tlvRegistry, this.viTlvRegistry);
ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspaObject1LowerBounds.bin"));
final LspaBuilder builder = new LspaBuilder();
@Test
public void testMetricObject() throws IOException, PCEPDeserializerException {
- final PCEPMetricObjectParser parser = new PCEPMetricObjectParser(this.tlvRegistry);
+ final PCEPMetricObjectParser parser = new PCEPMetricObjectParser();
ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPMetricObject1LowerBounds.bin"));
final MetricBuilder builder = new MetricBuilder();
@Test
public void testNoPathObjectWithTlv() throws PCEPDeserializerException, IOException {
- final PCEPNoPathObjectParser parser = new PCEPNoPathObjectParser(this.tlvRegistry);
+ final PCEPNoPathObjectParser parser = new PCEPNoPathObjectParser(this.tlvRegistry, this.viTlvRegistry);
ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPNoPathObject1WithoutTLV.bin"));
final NoPathBuilder builder = new NoPathBuilder();
builder.setIgnore(true);
builder.setNatureOfIssue((short) 1);
builder.setUnsatisfiedConstraints(true);
+ builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.no.path.TlvsBuilder().build());
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
ByteBuf buf = Unpooled.buffer();
@Test
public void testNotifyObjectWithTlv() throws PCEPDeserializerException, IOException {
- final PCEPNotificationObjectParser parser = new PCEPNotificationObjectParser(this.tlvRegistry);
+ final PCEPNotificationObjectParser parser = new PCEPNotificationObjectParser(this.tlvRegistry, this.viTlvRegistry);
ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPNotificationObject2WithoutTlv.bin"));
final CNotificationBuilder builder = new CNotificationBuilder();
@Test
public void testRPObjectWithTlv() throws PCEPDeserializerException, IOException {
- final PCEPRequestParameterObjectParser parser = new PCEPRequestParameterObjectParser(this.tlvRegistry);
+ final PCEPRequestParameterObjectParser parser = new PCEPRequestParameterObjectParser(this.tlvRegistry, this.viTlvRegistry);
ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPRPObject1.bin"));
final RpBuilder builder = new RpBuilder();
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().build());
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
ByteBuf buf = Unpooled.buffer();
@Test
public void testSvecObject() throws IOException, PCEPDeserializerException {
- final PCEPSvecObjectParser parser = new PCEPSvecObjectParser(this.tlvRegistry);
+ final PCEPSvecObjectParser parser = new PCEPSvecObjectParser();
ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPSvecObject2.bin"));
final SvecBuilder builder = new SvecBuilder();
@Test
public void testClassTypeObject() throws PCEPDeserializerException {
- final PCEPClassTypeObjectParser parser = new PCEPClassTypeObjectParser(this.tlvRegistry);
+ final PCEPClassTypeObjectParser parser = new PCEPClassTypeObjectParser();
final ByteBuf result = Unpooled.wrappedBuffer(new byte[] { (byte) 0x16, (byte) 0x12, (byte) 0x00, (byte) 0x08, 0, 0, 0, (byte) 0x04 });
final ClassTypeBuilder builder = new ClassTypeBuilder();
@Test
public void testObjectiveFunctionObject() throws IOException, PCEPDeserializerException {
- final PCEPObjectiveFunctionObjectParser parser = new PCEPObjectiveFunctionObjectParser(this.tlvRegistry);
+ final PCEPObjectiveFunctionObjectParser parser = new PCEPObjectiveFunctionObjectParser(this.tlvRegistry, this.viTlvRegistry);
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPObjectiveFunctionObject.1.bin"));
final OfBuilder builder = new OfBuilder();
builder.setProcessingRule(true);
builder.setIgnore(false);
builder.setCode(new OfId(4));
+ builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.object.of.TlvsBuilder().build());
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false), result.slice(4, result.readableBytes() - 4)));
ByteBuf buf = Unpooled.buffer();
@Test
public void testGlobalConstraintsObject() throws IOException, PCEPDeserializerException {
- final PCEPGlobalConstraintsObjectParser parser = new PCEPGlobalConstraintsObjectParser(this.tlvRegistry);
+ final PCEPGlobalConstraintsObjectParser parser = new PCEPGlobalConstraintsObjectParser(this.tlvRegistry, this.viTlvRegistry);
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPGlobalConstraintsObject.1.bin"));
final GcBuilder builder = new GcBuilder();
builder.setMaxUtilization((short) 0);
builder.setMinUtilization((short) 100);
builder.setOverBookingFactor((short) 99);
+ builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.gc.object.gc.TlvsBuilder().build());
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false), result.slice(4, result.readableBytes() - 4)));
ByteBuf buf = Unpooled.buffer();
@Test
public void testLspaObjectSerializerDefence() throws IOException, PCEPDeserializerException {
- final PCEPLspaObjectParser parser = new PCEPLspaObjectParser(this.tlvRegistry);
+ final PCEPLspaObjectParser parser = new PCEPLspaObjectParser(this.tlvRegistry, this.viTlvRegistry);
ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspaObject1LowerBounds.bin"));
final LspaBuilder builder = new LspaBuilder();
final byte[] expected = {0x07, 0x13, 0x00, 0x04};
assertArrayEquals(expected, ByteArray.getAllBytes(buffer));
}
+
+ @Test
+ public void testCloseObjectWithVendorInformationTlv() throws IOException, PCEPDeserializerException {
+ final byte[] closeBytes = {
+ 0x0f, 0x10, 0x00, 0x14,
+ 0x00, 0x00, 0x00, 0x05,
+ /* vendor-information TLV */
+ 0x00, 0x07, 0x00, 0x08,
+ /* enterprise number */
+ 0x00, 0x00, 0x00, 0x00,
+ /* enterprise specific information */
+ 0x00, 0x00, 0x00, 0x05
+ };
+ final PCEPCloseObjectParser parser = new PCEPCloseObjectParser(this.tlvRegistry, this.viTlvRegistry);
+ final ByteBuf result = Unpooled.wrappedBuffer(closeBytes);
+
+ final TestEnterpriseSpecificInformation esInfo = new TestEnterpriseSpecificInformation(5);
+ final VendorInformationTlv viTlv = new VendorInformationTlvBuilder().setEnterpriseNumber(new EnterpriseNumber(0L))
+ .setEnterpriseSpecificInformation(esInfo).build();
+ final CCloseBuilder builder = new CCloseBuilder();
+ builder.setProcessingRule(false);
+ builder.setIgnore(false);
+ builder.setReason((short) 5);
+ builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.object.c.close.TlvsBuilder()
+ .setVendorInformationTlv(Lists.newArrayList(viTlv)).build());
+
+ 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(result.array(), ByteArray.getAllBytes(buf));
+ }
}
import io.netty.buffer.Unpooled;
import java.util.List;
import org.junit.Test;
+import org.opendaylight.protocol.pcep.impl.TestVendorInformationTlvParser.TestEnterpriseSpecificInformation;
import org.opendaylight.protocol.pcep.impl.tlv.AbstractVendorSpecificTlvParser;
import org.opendaylight.protocol.pcep.impl.tlv.NoPathVectorTlvParser;
import org.opendaylight.protocol.pcep.impl.tlv.OFListTlvParser;
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;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.tlvs.VendorInformationTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.tlvs.VendorInformationTlvBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vs.tlv.VsTlv;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vs.tlv.VsTlvBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vs.tlv.vs.tlv.VendorPayload;
private static final byte[] ofListBytes = { 0x00, 0x04, 0x00, 0x04, 0x12, 0x34, 0x56, 0x78 };
private static final byte[] vsTlvBytes = { 0x00, 0x1b, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x09, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00,
0x05 };
+ private static final byte[] VENDOR_INFO_BYTES = {
+ 0x00, 0x07, 0x00, 0x08,
+ /* Enterprise number */
+ 0x00, 0x00, 0x00, 0x00,
+ /* Enterprise specific information */
+ 0x00, 0x00, 0x00, 0x05
+ };
private final AbstractVendorSpecificTlvParser vsParser = new AbstractVendorSpecificTlvParser() {
@Test
public void testVendorSpecificTlv() throws PCEPDeserializerException {
- VsTlv tlv = new VsTlvBuilder().setEnterpriseNumber(new EnterpriseNumber(9L)).setVendorPayload(this.vp).build();
+ final VsTlv tlv = new VsTlvBuilder().setEnterpriseNumber(new EnterpriseNumber(9L)).setVendorPayload(this.vp).build();
assertEquals(tlv, this.vsParser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(vsTlvBytes, 4))));
final ByteBuf buff = Unpooled.buffer();
this.vsParser.serializeTlv(tlv, buff);
assertArrayEquals(vsTlvBytes, ByteArray.getAllBytes(buff));
}
+
+ @Test
+ public void testVendorInformationTlv() throws PCEPDeserializerException {
+ final TestVendorInformationTlvParser parser = new TestVendorInformationTlvParser();
+ final TestEnterpriseSpecificInformation esInfo = new TestEnterpriseSpecificInformation(5);
+ final VendorInformationTlv viTlv = new VendorInformationTlvBuilder().setEnterpriseNumber(new EnterpriseNumber(0L))
+ .setEnterpriseSpecificInformation(esInfo).build();
+
+ final VendorInformationTlv parsedTlv = parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(VENDOR_INFO_BYTES, 8)));
+ assertEquals(viTlv, parsedTlv);
+
+ final ByteBuf buff = Unpooled.buffer(VENDOR_INFO_BYTES.length);
+ parser.serializeTlv(viTlv, buff);
+ assertArrayEquals(VENDOR_INFO_BYTES, ByteArray.getAllBytes(buff));
+ }
}
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.close.message.CCloseMessageBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.object.CCloseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.object.c.close.TlvsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.Ipv4CaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.ipv4._case.Ipv4Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.object.EndpointsObj;
rpBuilder.setEroCompression(false);
rpBuilder.setPriority((short) 1);
rpBuilder.setRequestId(new RequestId(10L));
+ rpBuilder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.rp.TlvsBuilder().build());
this.rpTrue = rpBuilder.build();
rpBuilder.setProcessingRule(false);
this.rpFalse = rpBuilder.build();
npbuilder.setIgnore(false);
npbuilder.setNatureOfIssue((short) 0);
npbuilder.setUnsatisfiedConstraints(false);
+ npbuilder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.no.path.TlvsBuilder().build());
this.noPath = npbuilder.build();
final LspaBuilder lspaBuilder = new LspaBuilder();
ofBuilder.setIgnore(false);
ofBuilder.setProcessingRule(false);
ofBuilder.setCode(new OfId(0));
+ ofBuilder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.object.of.TlvsBuilder().build());
this.of = ofBuilder.build();
final Ipv4Builder afi = new Ipv4Builder();
final PCEPCloseMessageParser parser = new PCEPCloseMessageParser(this.objectRegistry);
final CloseBuilder builder = new CloseBuilder().setCCloseMessage(new CCloseMessageBuilder().setCClose(
- new CCloseBuilder().setIgnore(false).setProcessingRule(false).setReason((short) 5).build()).build());
+ new CCloseBuilder().setIgnore(false).setProcessingRule(false).setReason((short) 5).setTlvs(new TlvsBuilder().build()).build()).build());
assertEquals(builder.build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.<Message> emptyList()));
final ByteBuf buf = Unpooled.buffer(result.readableBytes());
--- /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.impl;
+
+import com.google.common.collect.Lists;
+import java.util.List;
+import org.opendaylight.protocol.pcep.impl.TestVendorInformationTlvParser.TestEnterpriseSpecificInformation;
+import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderContext;
+import org.opendaylight.protocol.pcep.spi.pojo.AbstractPCEPExtensionProviderActivator;
+
+public class TestVendorInformationActivator extends AbstractPCEPExtensionProviderActivator {
+
+ @Override
+ protected List<AutoCloseable> startImpl(PCEPExtensionProviderContext context) {
+ final List<AutoCloseable> regs = Lists.newArrayList();
+ final TestVendorInformationTlvParser parser = new TestVendorInformationTlvParser();
+ regs.add(context.registerVendorInformationTlvParser(parser.getEnterpriseNumber(), parser));
+ regs.add(context.registerVendorInformationTlvSerializer(TestEnterpriseSpecificInformation.class, parser));
+ return regs;
+ }
+
+}
--- /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.impl;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.protocol.pcep.impl.tlv.AbstractVendorInformationTlvParser;
+import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.EnterpriseSpecificInformation;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+
+public class TestVendorInformationTlvParser extends AbstractVendorInformationTlvParser {
+
+ private static final EnterpriseNumber TEST_ENTERPRISE_NUMBER = new EnterpriseNumber(0L);
+
+ @Override
+ public void serializeEnterpriseSpecificInformation(final EnterpriseSpecificInformation enterpriseSpecificInformation,
+ final ByteBuf buffer) {
+ if (enterpriseSpecificInformation instanceof TestEnterpriseSpecificInformation) {
+ buffer.writeInt(((TestEnterpriseSpecificInformation) enterpriseSpecificInformation).getValue());
+ }
+ }
+
+ @Override
+ public EnterpriseSpecificInformation parseEnterpriseSpecificInformation(final ByteBuf buffer)
+ throws PCEPDeserializerException {
+ return new TestEnterpriseSpecificInformation(buffer.readInt());
+ }
+
+ @Override
+ public EnterpriseNumber getEnterpriseNumber() {
+ return TEST_ENTERPRISE_NUMBER;
+ }
+
+ protected static final class TestEnterpriseSpecificInformation implements EnterpriseSpecificInformation {
+
+ private final int value;
+
+ public TestEnterpriseSpecificInformation(final int value) {
+ this.value = value;
+ }
+
+ public int getValue() {
+ return value;
+ }
+
+ @Override
+ public Class<? extends DataContainer> getImplementedInterface() {
+ return TestEnterpriseSpecificInformation.class;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + value;
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ TestEnterpriseSpecificInformation other = (TestEnterpriseSpecificInformation) obj;
+ if (value != other.value) {
+ return false;
+ }
+ return true;
+ }
+ }
+
+}
import io.netty.buffer.ByteBuf;
import org.opendaylight.protocol.pcep.ietf.initiated00.CInitiated00SrpObjectParser;
import org.opendaylight.protocol.pcep.spi.TlvRegistry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.SrpBuilder;
+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;
public class CInitiated00SrpObjectWithPstTlvParser extends CInitiated00SrpObjectParser {
- public CInitiated00SrpObjectWithPstTlvParser(TlvRegistry tlvReg) {
- super(tlvReg);
+ public CInitiated00SrpObjectWithPstTlvParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
+ super(tlvReg, viTlvReg);
}
@Override
- public void addTlv(SrpBuilder builder, Tlv tlv) {
+ public void addTlv(final TlvsBuilder builder, final Tlv tlv) {
super.addTlv(builder, tlv);
final Tlvs7Builder tlvBuilder = new Tlvs7Builder();
- if (builder.getTlvs() != null) {
- final Tlvs7 tlvs = builder.getTlvs().getAugmentation(Tlvs7.class);
+ if (builder != null) {
+ 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.setTlvs(new TlvsBuilder().addAugmentation(Tlvs7.class, tlvBuilder.build()).build());
+ builder.addAugmentation(Tlvs7.class, tlvBuilder.build());
}
@Override
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.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.RpBuilder;
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(TlvRegistry tlvReg) {
- super(tlvReg);
+ public PcepRpObjectWithPstTlvParser(TlvRegistry tlvReg, VendorInformationTlvRegistry viTlvReg) {
+ super(tlvReg, viTlvReg);
}
@Override
- public void addTlv(RpBuilder builder, Tlv tlv) {
+ public void addTlv(final TlvsBuilder builder, Tlv tlv) {
super.addTlv(builder, tlv);
final Tlvs1Builder tlvBuilder = new Tlvs1Builder();
- if (builder.getTlvs() != null) {
- final Tlvs1 tlvs = builder.getTlvs().getAugmentation(Tlvs1.class);
+ if (builder != null) {
+ 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.setTlvs(new TlvsBuilder().addAugmentation(Tlvs1.class, tlvBuilder.build()).build());
+ builder.addAugmentation(Tlvs1.class, tlvBuilder.build()).build();
}
@Override
package org.opendaylight.protocol.pcep.segment.routing02;
import io.netty.buffer.ByteBuf;
-
import org.opendaylight.protocol.pcep.impl.object.PCEPOpenObjectParser;
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.segment.routing._02.rev140506.Tlvs1;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.Tlvs1Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing._02.rev140506.sr.pce.capability.tlv.SrPceCapability;
public class PcepOpenObjectWithSpcTlvParser extends PCEPOpenObjectParser {
- public PcepOpenObjectWithSpcTlvParser(TlvRegistry tlvReg) {
- super(tlvReg);
+ public PcepOpenObjectWithSpcTlvParser(TlvRegistry tlvReg, VendorInformationTlvRegistry viTlvReg) {
+ super(tlvReg, viTlvReg);
}
@Override
import org.opendaylight.protocol.pcep.spi.ObjectRegistry;
import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderContext;
import org.opendaylight.protocol.pcep.spi.TlvRegistry;
+import org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry;
import org.opendaylight.protocol.pcep.spi.pojo.AbstractPCEPExtensionProviderActivator;
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;
/* Objects */
final TlvRegistry tlvReg = context.getTlvHandlerRegistry();
+ final VendorInformationTlvRegistry viTlvRegistry = context.getVendorInformationTlvRegistry();
regs.add(context.registerObjectParser(CInitiated00SrpObjectWithPstTlvParser.CLASS,
- CInitiated00SrpObjectWithPstTlvParser.TYPE, new CInitiated00SrpObjectWithPstTlvParser(tlvReg)));
+ CInitiated00SrpObjectWithPstTlvParser.TYPE, new CInitiated00SrpObjectWithPstTlvParser(tlvReg, viTlvRegistry)));
regs.add(context.registerObjectParser(PcepRpObjectWithPstTlvParser.CLASS, PcepRpObjectWithPstTlvParser.TYPE,
- new PcepRpObjectWithPstTlvParser(tlvReg)));
+ new PcepRpObjectWithPstTlvParser(tlvReg, viTlvRegistry)));
regs.add(context.registerObjectParser(PcepOpenObjectWithSpcTlvParser.CLASS,
- PcepOpenObjectWithSpcTlvParser.TYPE, new PcepOpenObjectWithSpcTlvParser(tlvReg)));
+ PcepOpenObjectWithSpcTlvParser.TYPE, new PcepOpenObjectWithSpcTlvParser(tlvReg, viTlvRegistry)));
- regs.add(context.registerObjectSerializer(Srp.class, new CInitiated00SrpObjectWithPstTlvParser(tlvReg)));
- regs.add(context.registerObjectSerializer(Rp.class, new PcepRpObjectWithPstTlvParser(tlvReg)));
- regs.add(context.registerObjectSerializer(Open.class, new PcepOpenObjectWithSpcTlvParser(tlvReg)));
+ 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 */
final ObjectRegistry objRegistry = context.getObjectHandlerRegistry();
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;
0x0, 0x1b, 0x0, 0x4, 0x0, 0x0, 0x0, 0x1 };
private TlvRegistry tlvRegistry;
+ private VendorInformationTlvRegistry viTlvRegistry;
private SimplePCEPExtensionProviderContext ctx;
private SegmentRoutingActivator act;
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);
+ final PcepRpObjectWithPstTlvParser parser = new PcepRpObjectWithPstTlvParser(this.tlvRegistry, this.viTlvRegistry);
final RpBuilder builder = new RpBuilder();
builder.setProcessingRule(false);
builder.setIgnore(false);
@Test
public void testSrpObjectWithPstTlvParser() throws PCEPDeserializerException {
- final CInitiated00SrpObjectWithPstTlvParser parser = new CInitiated00SrpObjectWithPstTlvParser(this.tlvRegistry);
+ final CInitiated00SrpObjectWithPstTlvParser parser = new CInitiated00SrpObjectWithPstTlvParser(this.tlvRegistry, this.viTlvRegistry);
final SrpBuilder builder = new SrpBuilder();
builder.setProcessingRule(false);
builder.setIgnore(false);
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.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
};
private TlvRegistry tlvRegistry;
+ private VendorInformationTlvRegistry viTlvRegistry;
private SimplePCEPExtensionProviderContext ctx;
private SegmentRoutingActivator act;
this.act = new SegmentRoutingActivator();
this.act.start(this.ctx);
this.tlvRegistry = this.ctx.getTlvHandlerRegistry();
+ this.viTlvRegistry = this.ctx.getVendorInformationTlvRegistry();
}
@Test
public void testOpenObjectWithSpcTlv() throws PCEPDeserializerException {
- final PcepOpenObjectWithSpcTlvParser parser = new PcepOpenObjectWithSpcTlvParser(tlvRegistry);
+ final PcepOpenObjectWithSpcTlvParser parser = new PcepOpenObjectWithSpcTlvParser(this.tlvRegistry, this.viTlvRegistry);
final OpenBuilder builder = new OpenBuilder();
builder.setProcessingRule(false);
*/
package org.opendaylight.protocol.pcep.spi;
+import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
+
+import java.util.List;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber;
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.vendor.information.tlvs.VendorInformationTlv;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger LOG = LoggerFactory.getLogger(AbstractObjectWithTlvsParser.class);
- private static final int TLV_TYPE_F_LENGTH = 2;
- private static final int TLV_LENGTH_F_LENGTH = 2;
- private static final int TLV_HEADER_LENGTH = TLV_LENGTH_F_LENGTH + TLV_TYPE_F_LENGTH;
-
public static final int PADDED_TO = 4;
private final TlvRegistry tlvReg;
- protected AbstractObjectWithTlvsParser(final TlvRegistry tlvReg) {
+ private final VendorInformationTlvRegistry viTlvReg;
+
+ protected AbstractObjectWithTlvsParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
this.tlvReg = Preconditions.checkNotNull(tlvReg);
+ this.viTlvReg = Preconditions.checkNotNull(viTlvReg);
}
protected final void parseTlvs(final T builder, final ByteBuf bytes) throws PCEPDeserializerException {
if (!bytes.isReadable()) {
return;
}
+ final List<VendorInformationTlv> viTlvs = Lists.newArrayList();
while (bytes.isReadable()) {
int type = bytes.readUnsignedShort();
int length = bytes.readUnsignedShort();
}
final ByteBuf tlvBytes = bytes.slice(bytes.readerIndex(), length);
LOG.trace("Parsing PCEP TLV : {}", ByteBufUtil.hexDump(tlvBytes));
- final Tlv tlv = this.tlvReg.parseTlv(type, tlvBytes);
- LOG.trace("Parsed PCEP TLV {}.", tlv);
- addTlv(builder, tlv);
+
+ if (VendorInformationUtil.isVendorInformationTlv(type)) {
+ final EnterpriseNumber enterpriseNumber = new EnterpriseNumber(tlvBytes.readUnsignedInt());
+ final Optional<VendorInformationTlv> viTlv = this.viTlvReg.parseVendorInformationTlv(enterpriseNumber, tlvBytes);
+ if(viTlv.isPresent()) {
+ LOG.trace("Parsed VENDOR-INFORMATION TLV {}.", viTlv.get());
+ viTlvs.add(viTlv.get());
+ }
+ } else {
+ final Tlv tlv = this.tlvReg.parseTlv(type, tlvBytes);
+ if(tlv != null) {
+ LOG.trace("Parsed PCEP TLV {}.", tlv);
+ addTlv(builder, tlv);
+ }
+ }
bytes.skipBytes(length + TlvUtil.getPadding(TlvUtil.HEADER_SIZE + length, TlvUtil.PADDED_TO));
}
+ addVendorInformationTlvs(builder, viTlvs);
}
protected final void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
protected void addTlv(final T builder, final Tlv tlv) {
// FIXME: No TLVs by default, fallback to augments
}
+
+ abstract protected void addVendorInformationTlvs(final T builder, final List<VendorInformationTlv> tlvs);
+
+ protected final void serializeVendorInformationTlvs(final List<VendorInformationTlv> tlvs, final ByteBuf buffer) {
+ if (tlvs != null && !tlvs.isEmpty()) {
+ for (final VendorInformationTlv tlv : tlvs) {
+ LOG.trace("Serializing VENDOR-INFORMATION TLV {}", tlv);
+ this.viTlvReg.serializeVendorInformationTlv(tlv, buffer);
+ LOG.trace("Serialized VENDOR-INFORMATION TLV : {}.", ByteBufUtil.hexDump(buffer));
+ }
+ }
+ }
}
--- /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.spi;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.EnterpriseSpecificInformation;
+
+public interface EnterpriseSpecificInformationParser {
+
+ void serializeEnterpriseSpecificInformation(final EnterpriseSpecificInformation enterpriseSpecificInformation, final ByteBuf buffer);
+
+ EnterpriseSpecificInformation parseEnterpriseSpecificInformation(final ByteBuf buffer) throws PCEPDeserializerException;
+
+ EnterpriseNumber getEnterpriseNumber();
+}
XROSubobjectRegistry getXROSubobjectHandlerRegistry();
TlvRegistry getTlvHandlerRegistry();
+
+ VendorInformationTlvRegistry getVendorInformationTlvRegistry();
}
*/
package org.opendaylight.protocol.pcep.spi;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber;
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.Tlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.EnterpriseSpecificInformation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.SubobjectType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.label.subobject.LabelType;
AutoCloseable registerTlvParser(int tlvType, TlvParser parser);
+ AutoCloseable registerVendorInformationTlvSerializer(Class<? extends EnterpriseSpecificInformation> esInformationClass, TlvSerializer serializer);
+
+ AutoCloseable registerVendorInformationTlvParser(EnterpriseNumber enterpriseNumber, TlvParser parser);
+
AutoCloseable registerXROSubobjectSerializer(Class<? extends SubobjectType> subobjectClass, XROSubobjectSerializer serializer);
AutoCloseable registerXROSubobjectParser(int subobjectType, XROSubobjectParser parser);
--- /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.spi;
+
+import com.google.common.base.Optional;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.tlvs.VendorInformationTlv;
+
+public interface VendorInformationTlvRegistry {
+
+ Optional<VendorInformationTlv> parseVendorInformationTlv(final EnterpriseNumber enterpriseNumber, final ByteBuf buffer) throws PCEPDeserializerException;
+
+ void serializeVendorInformationTlv(final VendorInformationTlv viTlv, final ByteBuf buffer);
+
+}
--- /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.spi;
+
+public class VendorInformationUtil {
+
+ public static final int VENDOR_INFORMATION_TLV_TYPE = 7;
+
+ private VendorInformationUtil() {
+ }
+
+ public static boolean isVendorInformationTlv(final int type) {
+ return type == VENDOR_INFORMATION_TLV_TYPE;
+ }
+}
import org.opendaylight.protocol.pcep.spi.TlvParser;
import org.opendaylight.protocol.pcep.spi.TlvRegistry;
import org.opendaylight.protocol.pcep.spi.TlvSerializer;
+import org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry;
import org.opendaylight.protocol.pcep.spi.XROSubobjectParser;
import org.opendaylight.protocol.pcep.spi.XROSubobjectRegistry;
import org.opendaylight.protocol.pcep.spi.XROSubobjectSerializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber;
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.Tlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.EnterpriseSpecificInformation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.SubobjectType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.label.subobject.LabelType;
private final SimpleRROSubobjectRegistry rroSubReg = new SimpleRROSubobjectRegistry();
private final SimpleXROSubobjectRegistry xroSubReg = new SimpleXROSubobjectRegistry();
private final SimpleTlvRegistry tlvReg = new SimpleTlvRegistry();
+ private final SimpleVendorInformationTlvRegistry viTlvReg = new SimpleVendorInformationTlvRegistry();
@Override
public final LabelRegistry getLabelHandlerRegistry() {
return this.tlvReg;
}
+ @Override
+ public VendorInformationTlvRegistry getVendorInformationTlvRegistry() {
+ return this.viTlvReg;
+ }
+
@Override
public final AutoCloseable registerLabelSerializer(final Class<? extends LabelType> labelClass, final LabelSerializer serializer) {
return this.labelReg.registerLabelSerializer(labelClass, serializer);
final XROSubobjectSerializer serializer) {
return this.xroSubReg.registerSubobjectSerializer(subobjectClass, serializer);
}
+
+ @Override
+ public AutoCloseable registerVendorInformationTlvSerializer(final
+ Class<? extends EnterpriseSpecificInformation> esInformationClass, final TlvSerializer serializer) {
+ return this.viTlvReg.registerVendorInformationTlvSerializer(esInformationClass, serializer);
+ }
+
+ @Override
+ public AutoCloseable registerVendorInformationTlvParser(final EnterpriseNumber enterpriseNumber, final TlvParser parser) {
+ return this.viTlvReg.registerVendorInformationTlvParser(enterpriseNumber, parser);
+ }
}
--- /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.spi.pojo;
+
+import com.google.common.base.Optional;
+import com.google.common.primitives.Ints;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.protocol.concepts.HandlerRegistry;
+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.VendorInformationTlvRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.EnterpriseSpecificInformation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.tlvs.VendorInformationTlv;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+
+public class SimpleVendorInformationTlvRegistry implements VendorInformationTlvRegistry {
+
+ private final HandlerRegistry<DataContainer, TlvParser, TlvSerializer> handlers = new HandlerRegistry<>();
+
+ public AutoCloseable registerVendorInformationTlvParser(final EnterpriseNumber enterpriseNumber, final TlvParser parser) {
+ return this.handlers.registerParser(Ints.checkedCast(enterpriseNumber.getValue()), parser);
+ }
+
+ public AutoCloseable registerVendorInformationTlvSerializer(final Class<? extends EnterpriseSpecificInformation> esInformationClass, final TlvSerializer serializer) {
+ return this.handlers.registerSerializer(esInformationClass, serializer);
+ }
+
+ @Override
+ public Optional<VendorInformationTlv> parseVendorInformationTlv(final EnterpriseNumber enterpriseNumber, final ByteBuf buffer) throws PCEPDeserializerException {
+ final TlvParser parser = this.handlers.getParser(Ints.checkedCast(enterpriseNumber.getValue()));
+ if (parser == null) {
+ return Optional.absent();
+ }
+ return Optional.of((VendorInformationTlv) parser.parseTlv(buffer));
+ }
+
+ @Override
+ public void serializeVendorInformationTlv(final VendorInformationTlv viTlv, final ByteBuf buffer) {
+ final TlvSerializer serializer = this.handlers.getSerializer(viTlv.getEnterpriseSpecificInformation().getImplementedInterface());
+ if (serializer == null) {
+ return;
+ }
+ serializer.serializeTlv(viTlv, buffer);
+ }
+
+
+}
import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
+import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.list.tlv.OfList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.list.tlv.OfListBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.tlvs.VendorInformationTlv;
public class AbstractObjectWithTlvsTest {
@Mock
private TlvRegistry tlvRegistry;
+ @Mock
+ private VendorInformationTlvRegistry viTlvRegistry;
+
private class Abs extends AbstractObjectWithTlvsParser<TlvsBuilder> {
- protected Abs(TlvRegistry tlvReg) {
- super(tlvReg);
+ protected Abs(TlvRegistry tlvReg, VendorInformationTlvRegistry viTlvReg) {
+ super(tlvReg, viTlvReg);
}
@Override
public void addTlv(final TlvsBuilder builder, final Tlv tlv) {
builder.setOfList((OfList) tlv);
}
+
+ @Override
+ protected void addVendorInformationTlvs(TlvsBuilder builder, List<VendorInformationTlv> tlvs) {
+ builder.setVendorInformationTlv(tlvs);
+ }
};
@Before
@Test
public void testParseTlvs() throws PCEPDeserializerException {
- Abs a = new Abs(this.tlvRegistry);
+ Abs a = new Abs(this.tlvRegistry, this.viTlvRegistry);
ByteBuf buffer = Unpooled.buffer();
a.serializeTlv(this.tlv, buffer);