Search in sources :

Example 81 with BitArray

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);
}
Also used : UnnumberedCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.UnnumberedCase) BitArray(org.opendaylight.protocol.util.BitArray) ByteBuf(io.netty.buffer.ByteBuf) UnnumberedSubobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.UnnumberedSubobject)

Example 82 with BitArray

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);
    }
}
Also used : BitArray(org.opendaylight.protocol.util.BitArray) ByteBuf(io.netty.buffer.ByteBuf)

Example 83 with BitArray

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));
}
Also used : NodeFlagBits(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.NodeFlagBits) BitArray(org.opendaylight.protocol.util.BitArray)

Example 84 with BitArray

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);
}
Also used : IgpBitsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.prefix.state.IgpBitsBuilder) BitArray(org.opendaylight.protocol.util.BitArray) UpDown(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.IgpBits.UpDown)

Example 85 with BitArray

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);
}
Also used : PrefixAttributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.path.attribute.link.state.attribute.prefix.attributes._case.PrefixAttributes) BitArray(org.opendaylight.protocol.util.BitArray) IgpBits(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.prefix.state.IgpBits)

Aggregations

BitArray (org.opendaylight.protocol.util.BitArray)100 ByteBuf (io.netty.buffer.ByteBuf)27 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)8 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)8 RSVPParsingException (org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException)6 IpPrefixSubobject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.IpPrefixSubobject)4 IpPrefixCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.IpPrefixCase)4 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)3 Weight (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.Weight)3 SubobjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.SubobjectBuilder)3 LabelType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.LabelType)3 SubobjectContainerBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.list.SubobjectContainerBuilder)3 IpPrefixCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.IpPrefixCaseBuilder)3 IpPrefixBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.ip.prefix._case.IpPrefixBuilder)3 ArrayList (java.util.ArrayList)2 ByteBufWriteUtil.writeFloat32 (org.opendaylight.protocol.util.ByteBufWriteUtil.writeFloat32)2 Stateful1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Stateful1)2 Nai (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.sr.subobject.Nai)2 RequestId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId)2 Flags (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.object.Monitoring.Flags)2