Search in sources :

Example 96 with BitArray

use of org.opendaylight.protocol.util.BitArray in project bgpcep by opendaylight.

the class Ipv4EroParser method serializeEroFlags.

static void serializeEroFlags(final ByteBuf buffer, final Boolean loose) {
    final BitArray flags = new BitArray(FLAGS_SIZE);
    flags.set(LOOSE, loose);
    flags.toByteBuf(buffer);
    buffer.writeZero(RESERVED_ERO);
}
Also used : BitArray(org.opendaylight.protocol.util.BitArray)

Example 97 with BitArray

use of org.opendaylight.protocol.util.BitArray in project bgpcep by opendaylight.

the class Ipv6EroParser method parseIpv6EroCase.

public static Ipv6EroCase parseIpv6EroCase(final ByteBuf buffer) {
    final Ipv6EroCaseBuilder builder = new Ipv6EroCaseBuilder();
    final BitArray flags = BitArray.valueOf(buffer, Ipv4EroParser.FLAGS_SIZE);
    builder.setLoose(flags.get(Ipv4EroParser.LOOSE));
    buffer.skipBytes(Ipv4EroParser.RESERVED_ERO);
    builder.setAddress(Ipv6Util.addressForByteBuf(buffer));
    return builder.build();
}
Also used : Ipv6EroCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.binding.sub.tlvs.binding.sub.tlv.Ipv6EroCaseBuilder) BitArray(org.opendaylight.protocol.util.BitArray)

Example 98 with BitArray

use of org.opendaylight.protocol.util.BitArray in project bgpcep by opendaylight.

the class AbstractSrSubobjectParser method serializeSubobject.

public ByteBuf serializeSubobject(final SrSubobject srSubobject) {
    final ByteBuf buffer = Unpooled.buffer(MINIMAL_LENGTH);
    // sid type
    writeUnsignedByte((short) (srSubobject.getSidType().getIntValue() << SID_TYPE_BITS_OFFSET), buffer);
    final BitArray bits = new BitArray(BITSET_LENGTH);
    bits.set(M_FLAG_POSITION, srSubobject.isMFlag());
    bits.set(C_FLAG_POSITION, srSubobject.isCFlag());
    if (srSubobject.getSid() == null) {
        bits.set(S_FLAG_POSITION, Boolean.TRUE);
    }
    if (srSubobject.getNai() == null) {
        bits.set(F_FLAG_POSITION, Boolean.TRUE);
    }
    // bits
    bits.toByteBuf(buffer);
    // sid
    Preconditions.checkArgument(srSubobject.getNai() != null || srSubobject.getSid() != null, "Both SID and NAI are absent in SR subobject.");
    if (srSubobject.getSid() != null) {
        if (srSubobject.isMFlag()) {
            writeUnsignedInt(srSubobject.getSid() << MPLS_LABEL_OFFSET, buffer);
        } else {
            writeUnsignedInt(srSubobject.getSid(), buffer);
        }
    }
    // nai
    final Nai nai = srSubobject.getNai();
    if (nai != null) {
        serializeNai(nai, srSubobject.getSidType(), buffer);
    }
    return buffer;
}
Also used : Nai(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.sr.subobject.Nai) BitArray(org.opendaylight.protocol.util.BitArray) ByteBuf(io.netty.buffer.ByteBuf)

Example 99 with BitArray

use of org.opendaylight.protocol.util.BitArray in project bgpcep by opendaylight.

the class AbstractSrSubobjectParser method parseSrSubobject.

protected static SrSubobject parseSrSubobject(final ByteBuf buffer) throws PCEPDeserializerException {
    final int sidTypeByte = buffer.readByte() >> SID_TYPE_BITS_OFFSET;
    final SidType sidType = SidType.forValue(sidTypeByte);
    final BitArray bitSet = BitArray.valueOf(buffer.readByte());
    final boolean f = bitSet.get(F_FLAG_POSITION);
    final boolean s = bitSet.get(S_FLAG_POSITION);
    final boolean c = bitSet.get(C_FLAG_POSITION);
    final boolean m = bitSet.get(M_FLAG_POSITION);
    if (f && s) {
        throw new PCEPDeserializerException("Both SID and NAI are absent in SR subobject.");
    }
    Long tmp = null;
    if (!s) {
        if (m) {
            tmp = buffer.readUnsignedInt() >>> MPLS_LABEL_OFFSET;
        } else {
            tmp = buffer.readUnsignedInt();
        }
    }
    final Long sid = tmp;
    final Nai nai;
    if (sidType != null && !f) {
        nai = parseNai(sidType, buffer);
    } else {
        nai = null;
    }
    return new SrSubobjectImpl(m, c, sidType, sid, nai);
}
Also used : SidType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.SidType) Nai(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.sr.subobject.Nai) BitArray(org.opendaylight.protocol.util.BitArray) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)

Example 100 with BitArray

use of org.opendaylight.protocol.util.BitArray in project bgpcep by opendaylight.

the class ObjectUtil method formatSubobject.

public static void formatSubobject(final int objectType, final int objectClass, final Boolean processingRule, final Boolean ignore, final ByteBuf body, final ByteBuf out) {
    out.writeByte(objectClass);
    final BitArray flags = new BitArray(FLAGS_SIZE);
    flags.set(IGNORED, ignore);
    flags.set(PROCESSED, processingRule);
    final byte flagB = flags.toByte();
    final int typeByte = objectType << FLAGS_SIZE | (flagB & 0xff);
    out.writeByte(typeByte);
    out.writeShort(body.writerIndex() + HEADER_SIZE);
    out.writeBytes(body);
}
Also used : BitArray(org.opendaylight.protocol.util.BitArray)

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