Search in sources :

Example 46 with Tlv

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv in project bgpcep by opendaylight.

the class AbstractObjectWithTlvsParser method parseTlvs.

protected final void parseTlvs(final T builder, final ByteBuf bytes) throws PCEPDeserializerException {
    checkArgument(bytes != null, "Array of bytes is mandatory. Can't be null.");
    if (!bytes.isReadable()) {
        return;
    }
    final List<VendorInformationTlv> viTlvs = new ArrayList<>();
    while (bytes.isReadable()) {
        final int type = bytes.readUnsignedShort();
        final int length = bytes.readUnsignedShort();
        if (length > bytes.readableBytes()) {
            throw new PCEPDeserializerException("Wrong length specified. Passed: " + length + "; Expected: <= " + bytes.readableBytes() + ".");
        }
        final ByteBuf tlvBytes = bytes.readSlice(length);
        LOG.trace("Parsing PCEP TLV : {}", ByteBufUtil.hexDump(tlvBytes));
        if (VendorInformationUtil.isVendorInformationTlv(type)) {
            final EnterpriseNumber enterpriseNumber = new EnterpriseNumber(ByteBufUtils.readUint32(tlvBytes));
            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(TlvUtil.getPadding(TlvUtil.HEADER_SIZE + length, TlvUtil.PADDED_TO));
    }
    addVendorInformationTlvs(builder, viTlvs);
}
Also used : VendorInformationTlv(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.tlvs.VendorInformationTlv) ArrayList(java.util.ArrayList) EnterpriseNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber) ByteBuf(io.netty.buffer.ByteBuf) VendorInformationTlv(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.tlvs.VendorInformationTlv) Tlv(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv)

Example 47 with Tlv

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv in project bgpcep by opendaylight.

the class PcepOpenObjectWithSpcTlvParser method addTlv.

@Override
public void addTlv(final TlvsBuilder tbuilder, final Tlv tlv) {
    super.addTlv(tbuilder, tlv);
    final Tlvs1Builder tlvBuilder = new Tlvs1Builder();
    if (tbuilder.augmentation(Tlvs1.class) != null) {
        final Tlvs1 tlvs = tbuilder.augmentation(Tlvs1.class);
        if (tlvs.getSrPceCapability() != null) {
            tlvBuilder.setSrPceCapability(tlvs.getSrPceCapability());
        }
    }
    if (tlv instanceof SrPceCapability) {
        tlvBuilder.setSrPceCapability((SrPceCapability) tlv);
    }
    tbuilder.addAugmentation(tlvBuilder.build());
}
Also used : SrPceCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.sr.pce.capability.tlv.SrPceCapability) Tlvs1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.Tlvs1Builder) Tlvs1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.Tlvs1)

Example 48 with Tlv

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv in project bgpcep by opendaylight.

the class Stateful07OpenObjectParser method addTlv.

@Override
public void addTlv(final TlvsBuilder tbuilder, final Tlv tlv) {
    super.addTlv(tbuilder, tlv);
    final Tlvs1Builder statefulBuilder = new Tlvs1Builder();
    if (tbuilder.getAugmentation(Tlvs1.class) != null) {
        final Tlvs1 t = tbuilder.getAugmentation(Tlvs1.class);
        if (t.getStateful() != null) {
            statefulBuilder.setStateful(t.getStateful());
        }
    }
    if (tlv instanceof Stateful) {
        statefulBuilder.setStateful((Stateful) tlv);
    }
    tbuilder.addAugmentation(Tlvs1.class, statefulBuilder.build());
}
Also used : Stateful(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.Stateful) Tlvs1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Tlvs1Builder) Tlvs1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Tlvs1)

Example 49 with Tlv

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv in project bgpcep by opendaylight.

the class Stateful07StatefulCapabilityTlvParser method serializeTlv.

@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
    Preconditions.checkArgument(tlv instanceof Stateful, "StatefulCapabilityTlv is mandatory.");
    final Stateful sct = (Stateful) tlv;
    TlvUtil.formatTlv(TYPE, Unpooled.wrappedBuffer(serializeFlags(sct).array()), buffer);
}
Also used : Stateful(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.Stateful)

Example 50 with Tlv

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv in project bgpcep by opendaylight.

the class PathBindingTlvParser method serializeTlv.

@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
    Preconditions.checkArgument(tlv instanceof PathBinding, "The TLV must be PathBinding type, but was %s", tlv.getClass());
    final PathBinding pTlv = (PathBinding) tlv;
    final BindingTypeValue bindingTypeValue = pTlv.getBindingTypeValue();
    Preconditions.checkArgument(bindingTypeValue != null, "Missing Binding Value in Path Bidning TLV: %s", pTlv);
    final ByteBuf body = Unpooled.buffer(MPLS_BINDING_LENGTH);
    final PathBindingTlvCodec codec = BT_SERIALIZERS.get(bindingTypeValue.getImplementedInterface());
    Preconditions.checkArgument(codec != null, "Unsupported Path Binding Type: %s", bindingTypeValue.getImplementedInterface());
    ByteBufWriteUtil.writeUnsignedShort(codec.getBindingType(), body);
    body.writeBytes(codec.serialize(bindingTypeValue));
    TlvUtil.formatTlv(TYPE, body, buffer);
}
Also used : BindingTypeValue(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.path.binding.tlv.path.binding.BindingTypeValue) ByteBuf(io.netty.buffer.ByteBuf) PathBinding(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.path.binding.tlv.PathBinding)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)59 Test (org.junit.Test)28 Tlv (es.gob.jmulticard.asn1.Tlv)11 ArrayList (java.util.ArrayList)10 TunnelId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.TunnelId)8 LspId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId)7 TlvException (es.gob.jmulticard.asn1.TlvException)6 Stateful (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.stateful.capability.tlv.Stateful)5 Ipv4ExtendedTunnelId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.Ipv4ExtendedTunnelId)5 Asn1Exception (es.gob.jmulticard.asn1.Asn1Exception)4 DecoderObject (es.gob.jmulticard.asn1.DecoderObject)4 BitArray (org.opendaylight.protocol.util.BitArray)4 Ipv6ExtendedTunnelId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.Ipv6ExtendedTunnelId)4 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)3 EnterpriseNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber)3 Stateful (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.Stateful)3 LspIdentifiers (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.LspIdentifiers)3 LspIdentifiersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.LspIdentifiersBuilder)3 AddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.lsp.identifiers.AddressFamily)3 RsvpErrorSpec (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.rsvp.error.spec.tlv.RsvpErrorSpec)3