use of org.opendaylight.protocol.util.BitArray in project bgpcep by opendaylight.
the class BindingSidLabelParser method serializeBindingSidAttributes.
public static void serializeBindingSidAttributes(final Weight weight, final Flags flags, final List<BindingSubTlvs> bindingSubTlvs, final ByteBuf aggregator) {
aggregator.writeByte(weight.getValue());
final BitArray bitFlags = serializeBindingSidFlags(flags);
bitFlags.toByteBuf(aggregator);
aggregator.writeZero(RESERVED_BINDING_SID);
SimpleBindingSubTlvsRegistry.getInstance().serializeBindingSubTlvs(bindingSubTlvs, aggregator);
}
use of org.opendaylight.protocol.util.BitArray in project bgpcep by opendaylight.
the class BindingSidLabelParser method serializeBindingSidFlags.
private static BitArray serializeBindingSidFlags(final Flags flags) {
final BitArray bitFlags = new BitArray(FLAGS_SIZE);
if (flags instanceof IsisBindingFlagsCase) {
final IsisBindingFlagsCase isisFlags = (IsisBindingFlagsCase) flags;
bitFlags.set(AFI, isisFlags.isAddressFamily());
bitFlags.set(MIRROR_CONTEXT, isisFlags.isMirrorContext());
bitFlags.set(SPREAD_TLV, isisFlags.isSpreadTlv());
bitFlags.set(LEAKED, isisFlags.isLeakedFromLevel2());
bitFlags.set(ATTACHED, isisFlags.isAttachedFlag());
} else if (flags instanceof OspfBindingFlagsCase) {
final OspfBindingFlagsCase ospfFlags = (OspfBindingFlagsCase) flags;
bitFlags.set(MIRROR_CONTEXT_OSPF, ospfFlags.isMirroring());
}
return bitFlags;
}
use of org.opendaylight.protocol.util.BitArray in project bgpcep by opendaylight.
the class RangeTlvParser method parseSrRange.
public static SrRange parseSrRange(final ByteBuf buffer, final ProtocolId protocolId) {
final BitArray flags = BitArray.valueOf(buffer, FLAGS_SIZE);
final SrRangeBuilder range = new SrRangeBuilder();
if (protocolId.equals(ProtocolId.Ospf)) {
range.setInterArea(flags.get(INNER_AREA));
} else {
range.setInterArea(Boolean.FALSE);
}
buffer.skipBytes(RESERVED);
range.setRangeSize(buffer.readUnsignedShort());
range.setSubTlvs(parseRangeSubTlvs(buffer, protocolId));
return range.build();
}
use of org.opendaylight.protocol.util.BitArray in project bgpcep by opendaylight.
the class SrLinkAttributesParser method serializeLanAdjacencySegmentIdentifier.
public static ByteBuf serializeLanAdjacencySegmentIdentifier(final SrLanAdjIds srLanAdjId) {
final ByteBuf value = Unpooled.buffer();
final BitArray flags = serializeAdjFlags(srLanAdjId.getFlags(), srLanAdjId.getSidLabelIndex());
flags.toByteBuf(value);
value.writeByte(srLanAdjId.getWeight().getValue());
value.writeZero(RESERVED);
if (srLanAdjId.getIsoSystemId() != null) {
value.writeBytes(srLanAdjId.getIsoSystemId().getValue());
} else if (srLanAdjId.getNeighborId() != null) {
value.writeBytes(Ipv4Util.byteBufForAddress(srLanAdjId.getNeighborId()));
}
value.writeBytes(SidLabelIndexParser.serializeSidValue(srLanAdjId.getSidLabelIndex()));
return value;
}
use of org.opendaylight.protocol.util.BitArray 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