use of org.opendaylight.protocol.util.BitArray in project bgpcep by opendaylight.
the class RROUnnumberedInterfaceSubobjectParser method serializeSubobject.
@Override
public void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
Preconditions.checkArgument(subobject.getSubobjectType() instanceof UnnumberedCase, "Unknown subobject instance. Passed %s. Needed UnnumberedCase.", subobject.getSubobjectType().getClass());
final UnnumberedSubobject specObj = ((UnnumberedCase) subobject.getSubobjectType()).getUnnumbered();
final BitArray flags = new BitArray(FLAGS_SIZE);
flags.set(LPA_F_OFFSET, subobject.isProtectionAvailable());
flags.set(LPIU_F_OFFSET, subobject.isProtectionInUse());
final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
flags.toByteBuf(body);
body.writeZero(RESERVED);
Preconditions.checkArgument(specObj.getRouterId() != null, "RouterId is mandatory.");
writeUnsignedInt(specObj.getRouterId(), body);
Preconditions.checkArgument(specObj.getInterfaceId() != null, "InterfaceId is mandatory.");
writeUnsignedInt(specObj.getInterfaceId(), body);
RROSubobjectUtil.formatSubobject(TYPE, body, buffer);
}
use of org.opendaylight.protocol.util.BitArray in project bgpcep by opendaylight.
the class LinkAttributesParser method serializeMplsProtocolMask.
private static void serializeMplsProtocolMask(final MplsProtocolMask mplsProtocolMask, final ByteBuf byteAggregator) {
if (mplsProtocolMask != null) {
final ByteBuf mplsProtocolMaskBuf = Unpooled.buffer(1);
final BitArray mask = new BitArray(FLAGS_SIZE);
mask.set(LDP_BIT, mplsProtocolMask.isLdp());
mask.set(RSVP_BIT, mplsProtocolMask.isRsvpte());
mask.toByteBuf(mplsProtocolMaskBuf);
TlvUtil.writeTLV(MPLS_PROTOCOL, mplsProtocolMaskBuf, byteAggregator);
}
}
use of org.opendaylight.protocol.util.BitArray in project bgpcep by opendaylight.
the class NodeAttributesParser method parseNodeFlags.
private static void parseNodeFlags(final ByteBuf value, final NodeAttributesBuilder builder) {
final BitArray flags = BitArray.valueOf(value, FLAGS_SIZE);
builder.setNodeFlags(new NodeFlagBits(flags.get(OVERLOAD_BIT), flags.get(ATTACHED_BIT), flags.get(EXTERNAL_BIT), flags.get(ABBR_BIT), flags.get(ROUTER_BIT), flags.get(V6_BIT)));
LOG.debug("Parsed Overload bit: {}, attached bit: {}, external bit: {}, area border router: {}.", flags.get(OVERLOAD_BIT), flags.get(ATTACHED_BIT), flags.get(EXTERNAL_BIT), flags.get(ABBR_BIT));
}
use of org.opendaylight.protocol.util.BitArray in project bgpcep by opendaylight.
the class PrefixAttributesParser method parseIgpFags.
private static void parseIgpFags(final PrefixAttributesBuilder builder, final ByteBuf value) {
final BitArray flags = BitArray.valueOf(value, FLAGS_SIZE);
final boolean upDownBit = flags.get(UP_DOWN_BIT);
builder.setIgpBits(new IgpBitsBuilder().setUpDown(new UpDown(upDownBit)).setIsIsUpDown(upDownBit).setOspfNoUnicast(flags.get(OSPF_NO_UNICAST)).setOspfLocalAddress(flags.get(OSPF_LOCAL_ADDRESS)).setOspfPropagateNssa(flags.get(OSPF_PROPAGATE_ADDRESS)).build());
LOG.debug("Parsed IGP flag (up/down bit) : {}", upDownBit);
}
use of org.opendaylight.protocol.util.BitArray in project bgpcep by opendaylight.
the class PrefixAttributesParser method serializePrefixAttributes.
static void serializePrefixAttributes(final PrefixAttributesCase prefixAttributesCase, final ByteBuf byteAggregator) {
final PrefixAttributes prefixAtrributes = prefixAttributesCase.getPrefixAttributes();
if (prefixAtrributes.getIgpBits() != null) {
final BitArray igpBit = new BitArray(FLAGS_SIZE);
final IgpBits igpBits = prefixAtrributes.getIgpBits();
igpBit.set(UP_DOWN_BIT, igpBits.getUpDown().isUpDown() || igpBits.isIsIsUpDown());
igpBit.set(OSPF_NO_UNICAST, igpBits.isOspfNoUnicast());
igpBit.set(OSPF_LOCAL_ADDRESS, igpBits.isOspfLocalAddress());
igpBit.set(OSPF_PROPAGATE_ADDRESS, igpBits.isOspfPropagateNssa());
TlvUtil.writeTLV(IGP_FLAGS, Unpooled.wrappedBuffer(igpBit.array()), byteAggregator);
}
serializeRouteTags(prefixAtrributes.getRouteTags(), byteAggregator);
serializeExtendedRouteTags(prefixAtrributes.getExtendedTags(), byteAggregator);
serializePrefixMetric(prefixAtrributes.getPrefixMetric(), byteAggregator);
serializeForwardingAddress(prefixAtrributes.getOspfForwardingAddress(), byteAggregator);
serializeSrPrefix(prefixAtrributes.getSrPrefix(), byteAggregator);
serializeIpv6SrPrefix(prefixAtrributes.getIpv6SrPrefix(), byteAggregator);
serializeSrRange(prefixAtrributes.getSrRange(), byteAggregator);
serializeSrBindingLabel(prefixAtrributes.getSrBindingSidLabels(), byteAggregator);
}
Aggregations