use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.labeled.unicast.LabelStack in project bgpcep by opendaylight.
the class LUNlriParser method serializeNlri.
protected static void serializeNlri(final List<CLabeledUnicastDestination> dests, final boolean isUnreachNlri, final ByteBuf buffer) {
final ByteBuf nlriByteBuf = Unpooled.buffer();
for (final CLabeledUnicastDestination dest : dests) {
PathIdUtil.writePathId(dest.getPathId(), buffer);
final List<LabelStack> labelStack = dest.getLabelStack();
final IpPrefix prefix = dest.getPrefix();
// Serialize the length field
// Length field contains one Byte which represents the length of label stack and prefix in bits
nlriByteBuf.writeByte(((LABEL_LENGTH * (!isUnreachNlri ? labelStack.size() : 1)) + getPrefixLength(prefix)) * Byte.SIZE);
serializeLabelStackEntries(labelStack, isUnreachNlri, nlriByteBuf);
serializePrefixField(prefix, nlriByteBuf);
}
buffer.writeBytes(nlriByteBuf);
}
Aggregations