Search in sources :

Example 1 with EpeAdjSidTlv

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.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()) {
        buffer.skipBytes(FLAGS_BYTE_SIZE);
        weight = new Weight(buffer.readUnsignedByte());
        buffer.skipBytes(RESERVED);
        sidValue = SidLabelIndexParser.parseSidLabelIndex(Size.forValue(buffer.readableBytes()), buffer);
    } else {
        weight = null;
        sidValue = null;
    }
    return new EpeAdjSidTlv() {

        @Override
        public Class<? extends DataContainer> getImplementedInterface() {
            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.rev151014.EpeAdjSidTlv) SidLabelIndex(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.sid.label.index.SidLabelIndex) Weight(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.Weight)

Example 2 with EpeAdjSidTlv

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.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);
    }
    value.writeByte(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.rev171207.linkstate.attribute.SrAdjIds) BitArray(org.opendaylight.protocol.util.BitArray) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

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