Search in sources :

Example 66 with Tlv

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.Tlv in project bgpcep by opendaylight.

the class OFListTlvParser method serializeTlv.

@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
    Preconditions.checkArgument(tlv instanceof OfList, "OFListTlv is mandatory.");
    final OfList oft = (OfList) tlv;
    final ByteBuf body = Unpooled.buffer();
    final List<OfId> ofCodes = oft.getCodes();
    for (OfId id : ofCodes) {
        writeUnsignedShort(id.getValue(), body);
    }
    TlvUtil.formatTlv(TYPE, body, buffer);
}
Also used : OfList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.list.tlv.OfList) OfId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OfId) ByteBuf(io.netty.buffer.ByteBuf)

Example 67 with Tlv

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.Tlv in project bgpcep by opendaylight.

the class OrderTlvParser method serializeTlv.

@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
    Preconditions.checkArgument(tlv instanceof Order, "OrderTlv is mandatory.");
    final Order otlv = (Order) tlv;
    final ByteBuf body = Unpooled.buffer();
    writeUnsignedInt(otlv.getDelete(), body);
    writeUnsignedInt(otlv.getSetup(), body);
    TlvUtil.formatTlv(TYPE, body, buffer);
}
Also used : Order(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.order.tlv.Order) ByteBuf(io.netty.buffer.ByteBuf)

Example 68 with Tlv

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.Tlv in project bgpcep by opendaylight.

the class PathSetupTypeTlvParser method serializeTlv.

@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
    Preconditions.checkArgument(tlv instanceof PathSetupType, "PathSetupType is mandatory.");
    final PathSetupType pstTlv = (PathSetupType) tlv;
    Preconditions.checkArgument(checkPST(pstTlv.getPst()), UNSUPPORTED_PST);
    final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
    body.writeZero(OFFSET);
    writeUnsignedByte(pstTlv.getPst(), body);
    TlvUtil.formatTlv(TYPE, body, buffer);
}
Also used : PathSetupType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupType) ByteBuf(io.netty.buffer.ByteBuf)

Example 69 with Tlv

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.Tlv in project bgpcep by opendaylight.

the class ReqMissingTlvParser method serializeTlv.

@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
    Preconditions.checkArgument(tlv instanceof ReqMissing, "ReqMissingTlv is mandatory.");
    final ReqMissing req = (ReqMissing) tlv;
    final ByteBuf body = Unpooled.buffer();
    Preconditions.checkArgument(req.getRequestId() != null, "RequestId is mandatory.");
    writeUnsignedInt(req.getRequestId().getValue(), body);
    TlvUtil.formatTlv(TYPE, body, buffer);
}
Also used : ReqMissing(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.req.missing.tlv.ReqMissing) ByteBuf(io.netty.buffer.ByteBuf)

Example 70 with Tlv

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.Tlv in project bgpcep by opendaylight.

the class AigpAttributeParser method serializeAigpTLV.

/**
 * Transform AIGP attribute data from instance of Aigp class into byte buffer representation.
 *
 * @param aigp
 *          instance of Aigp class
 * @return
 *          byte buffer representation or empty buffer if AIGP TLV is null
 */
private static ByteBuf serializeAigpTLV(final Aigp aigp) {
    final AigpTlv tlv = aigp.getAigpTlv();
    if (tlv == null) {
        return Unpooled.EMPTY_BUFFER;
    }
    final ByteBuf value = Unpooled.buffer(AIGP_TLV_SIZE);
    value.writeByte(AIGP_TLV_TYPE);
    value.writeShort(AIGP_TLV_SIZE);
    value.writeLong(tlv.getMetric().getValue().longValue());
    return value;
}
Also used : AigpTlv(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.aigp.AigpTlv) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)53 Test (org.junit.Test)29 Tlv (es.gob.jmulticard.asn1.Tlv)11 ArrayList (java.util.ArrayList)8 TlvException (es.gob.jmulticard.asn1.TlvException)6 Asn1Exception (es.gob.jmulticard.asn1.Asn1Exception)4 DecoderObject (es.gob.jmulticard.asn1.DecoderObject)4 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)4 LspIdentifiersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.LspIdentifiersBuilder)4 Stateful (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.Stateful)4 LspId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId)4 TunnelId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.TunnelId)4 EnterpriseNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber)3 LspIdentifiers (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.LspIdentifiers)3 RsvpErrorSpec (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.rsvp.error.spec.tlv.RsvpErrorSpec)3 VendorInformationTlv (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.tlvs.VendorInformationTlv)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 BmpDeserializationException (org.opendaylight.protocol.bmp.spi.parser.BmpDeserializationException)2 Stateful07RSVPErrorSpecTlvParser (org.opendaylight.protocol.pcep.ietf.stateful07.Stateful07RSVPErrorSpecTlvParser)2 BitArray (org.opendaylight.protocol.util.BitArray)2