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;
}
};
}
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;
}
Aggregations