Search in sources :

Example 86 with BitArray

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

Example 87 with BitArray

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;
}
Also used : OspfBindingFlagsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.binding.sid.tlv.flags.OspfBindingFlagsCase) IsisBindingFlagsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.binding.sid.tlv.flags.IsisBindingFlagsCase) BitArray(org.opendaylight.protocol.util.BitArray)

Example 88 with BitArray

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

Example 89 with BitArray

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

Example 90 with BitArray

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

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