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