Search in sources :

Example 1 with EpeAdjSidTlv

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.EpeAdjSidTlv in project bgpcep by opendaylight.

the class SrLinkAttributesParser method parseEpeAdjacencySegmentIdentifier.

public static EpeAdjSidTlv parseEpeAdjacencySegmentIdentifier(final ByteBuf buffer) {
    final Weight weight;
    final SidLabelIndex sidValue;
    if (buffer.isReadable()) {
        final BitArray flags = BitArray.valueOf(buffer, FLAGS_BITS_SIZE);
        weight = new Weight(readUint8(buffer));
        buffer.skipBytes(RESERVED);
        sidValue = SidLabelIndexParser.parseSidLabelIndexByFlags(Size.forValue(buffer.readableBytes()), buffer, flags.get(VALUE_EPE), flags.get(LOCAL_EPE));
    } else {
        weight = null;
        sidValue = null;
    }
    return new EpeAdjSidTlv() {

        @Override
        public Class<EpeAdjSidTlv> implementedInterface() {
            return EpeAdjSidTlv.class;
        }

        @Override
        public Weight getWeight() {
            return weight;
        }

        @Override
        public SidLabelIndex getSidLabelIndex() {
            return sidValue;
        }
    };
}
Also used : EpeAdjSidTlv(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.EpeAdjSidTlv) SidLabelIndex(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.sid.label.index.SidLabelIndex) BitArray(org.opendaylight.protocol.util.BitArray) Weight(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.Weight)

Example 2 with EpeAdjSidTlv

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.EpeAdjSidTlv in project bgpcep by opendaylight.

the class SrLinkAttributesParser method serializeAdjacencySegmentIdentifier.

public static <T extends EpeAdjSidTlv> ByteBuf serializeAdjacencySegmentIdentifier(final T adjSid) {
    final ByteBuf value = Unpooled.buffer();
    if (adjSid instanceof SrAdjIds) {
        final BitArray flags = serializeAdjFlags(((SrAdjIds) adjSid).getFlags(), adjSid.getSidLabelIndex());
        flags.toByteBuf(value);
    } else {
        value.writeZero(FLAGS_BYTE_SIZE);
    }
    writeUint8(value, adjSid.getWeight().getValue());
    value.writeZero(RESERVED);
    value.writeBytes(SidLabelIndexParser.serializeSidValue(adjSid.getSidLabelIndex()));
    return value;
}
Also used : SrAdjIds(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.SrAdjIds) BitArray(org.opendaylight.protocol.util.BitArray) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

BitArray (org.opendaylight.protocol.util.BitArray)2 ByteBuf (io.netty.buffer.ByteBuf)1 SrAdjIds (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.SrAdjIds)1 EpeAdjSidTlv (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.EpeAdjSidTlv)1 Weight (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.Weight)1 SidLabelIndex (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.sid.label.index.SidLabelIndex)1