Search in sources :

Example 66 with BitArray

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

the class SyncOptimizationsCapabilityTlvParser method serializeFlags.

@Override
protected BitArray serializeFlags(final Stateful sct) {
    final BitArray flags = new BitArray(FLAGS_F_LENGTH);
    final Stateful1 sfi = sct.getAugmentation(Stateful1.class);
    final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Stateful1 sf2 = sct.getAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Stateful1.class);
    if (sf2 != null) {
        flags.set(F_FLAG_OFFSET, sf2.isTriggeredInitialSync());
        flags.set(D_FLAG_OFFSET, sf2.isDeltaLspSyncCapability());
        flags.set(T_FLAG_OFFSET, sf2.isTriggeredResync());
        flags.set(S_FLAG_OFFSET, sf2.isIncludeDbVersion());
    }
    if (sfi != null) {
        flags.set(I_FLAG_OFFSET, sfi.isInitiation());
    }
    flags.set(U_FLAG_OFFSET, sct.isLspUpdateCapability());
    return flags;
}
Also used : Stateful1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Stateful1) BitArray(org.opendaylight.protocol.util.BitArray)

Example 67 with BitArray

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

the class Stateful07RSVPErrorSpecTlvParser method parseRsvp.

private static RsvpCase parseRsvp(final int classType, final ByteBuf buffer) {
    final RsvpErrorBuilder builder = new RsvpErrorBuilder();
    if (classType == RSVP_IPV4_ERROR_CLASS_TYPE) {
        builder.setNode(new IpAddress(Ipv4Util.addressForByteBuf(buffer)));
    } else if (classType == RSVP_IPV6_ERROR_CLASS_TYPE) {
        builder.setNode(new IpAddress(Ipv6Util.addressForByteBuf(buffer)));
    }
    final BitArray flags = BitArray.valueOf(buffer, FLAGS_SIZE);
    builder.setFlags(new Flags(flags.get(IN_PLACE), flags.get(NOT_GUILTY)));
    final short errorCode = buffer.readUnsignedByte();
    builder.setCode(errorCode);
    final int errorValue = buffer.readUnsignedShort();
    builder.setValue(errorValue);
    return new RsvpCaseBuilder().setRsvpError(builder.build()).build();
}
Also used : RsvpCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.rsvp.error.spec.tlv.rsvp.error.spec.error.type.RsvpCaseBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) BitArray(org.opendaylight.protocol.util.BitArray) Flags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ErrorSpec.Flags) RsvpErrorBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.rsvp.error.spec.tlv.rsvp.error.spec.error.type.rsvp._case.RsvpErrorBuilder)

Example 68 with BitArray

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

the class Stateful07RSVPErrorSpecTlvParser method serializeRsvp.

private static void serializeRsvp(final RsvpError rsvp, final ByteBuf body) {
    final BitArray flags = new BitArray(FLAGS_SIZE);
    flags.set(IN_PLACE, rsvp.getFlags().isInPlace());
    flags.set(NOT_GUILTY, rsvp.getFlags().isNotGuilty());
    final IpAddress node = rsvp.getNode();
    Preconditions.checkArgument(node != null, "Node is mandatory.");
    final ByteBuf rsvpObjBuf = Unpooled.buffer();
    int type = 0;
    if (node.getIpv4Address() != null) {
        type = RSVP_IPV4_ERROR_CLASS_TYPE;
        writeIpv4Address(node.getIpv4Address(), rsvpObjBuf);
    } else {
        type = RSVP_IPV6_ERROR_CLASS_TYPE;
        writeIpv6Address(node.getIpv6Address(), rsvpObjBuf);
    }
    flags.toByteBuf(rsvpObjBuf);
    Preconditions.checkArgument(rsvp.getCode() != null, "Code is mandatory.");
    writeUnsignedByte(rsvp.getCode(), rsvpObjBuf);
    Preconditions.checkArgument(rsvp.getValue() != null, "Value is mandatory.");
    writeUnsignedShort(rsvp.getValue(), rsvpObjBuf);
    formatRSVPObject(RSVP_ERROR_CLASS_NUM, type, rsvpObjBuf, body);
}
Also used : IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) BitArray(org.opendaylight.protocol.util.BitArray) ByteBuf(io.netty.buffer.ByteBuf)

Example 69 with BitArray

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

the class Stateful07StatefulCapabilityTlvParser method serializeFlags.

protected BitArray serializeFlags(final Stateful sct) {
    final BitArray flags = new BitArray(FLAGS_F_LENGTH);
    flags.set(U_FLAG_OFFSET, sct.isLspUpdateCapability());
    return flags;
}
Also used : BitArray(org.opendaylight.protocol.util.BitArray)

Example 70 with BitArray

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

the class Stateful07LspObjectParser method parseFlags.

protected void parseFlags(final LspBuilder builder, final ByteBuf bytes) {
    final BitArray flags = BitArray.valueOf(bytes, FLAGS_SIZE);
    builder.setDelegate(flags.get(DELEGATE));
    builder.setSync(flags.get(SYNC));
    builder.setRemove(flags.get(REMOVE));
    builder.setAdministrative(flags.get(ADMINISTRATIVE));
    short s = 0;
    s |= flags.get(OPERATIONAL + 2) ? 1 : 0;
    s |= (flags.get(OPERATIONAL + 1) ? 1 : 0) << 1;
    s |= (flags.get(OPERATIONAL) ? 1 : 0) << 2;
    builder.setOperational(OperationalStatus.forValue(s));
}
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