Search in sources :

Example 71 with BitArray

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

the class Stateful07LspObjectParser method serializeObject.

@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
    Preconditions.checkArgument(object instanceof Lsp, "Wrong instance of PCEPObject. Passed %s . Needed LspObject.", object.getClass());
    final Lsp specObj = (Lsp) object;
    final ByteBuf body = Unpooled.buffer();
    Preconditions.checkArgument(specObj.getPlspId() != null, "PLSP-ID not present");
    writeMedium(specObj.getPlspId().getValue().intValue() << FOUR_BITS_SHIFT, body);
    final BitArray flags = serializeFlags(specObj);
    byte op = 0;
    if (specObj.getOperational() != null) {
        op = UnsignedBytes.checkedCast(specObj.getOperational().getIntValue());
        op = (byte) (op << FOUR_BITS_SHIFT);
    }
    final byte[] res = flags.array();
    res[res.length - 1] = (byte) (res[res.length - 1] | op);
    body.writeByte(res[res.length - 1]);
    serializeTlvs(specObj.getTlvs(), body);
    ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
Also used : Lsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.Lsp) BitArray(org.opendaylight.protocol.util.BitArray) ByteBuf(io.netty.buffer.ByteBuf)

Example 72 with BitArray

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

the class NoPathVectorTlvParser method serializeTlv.

@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
    Preconditions.checkArgument(tlv instanceof NoPathVector, "NoPathVectorTlv is mandatory.");
    final NoPathVector noPath = (NoPathVector) tlv;
    final ByteBuf body = Unpooled.buffer();
    final BitArray flags = new BitArray(FLAGS_SIZE);
    final Flags f = noPath.getFlags();
    flags.set(REACHABLITY_PROBLEM, f.isP2mpUnreachable());
    flags.set(NO_GCO_SOLUTION, f.isNoGcoSolution());
    flags.set(NO_GCO_MIGRATION_PATH, f.isNoGcoMigration());
    flags.set(PATH_KEY, f.isPathKey());
    flags.set(CHAIN_UNAVAILABLE, f.isChainUnavailable());
    flags.set(UNKNOWN_SRC, f.isUnknownSource());
    flags.set(UNKNOWN_DEST, f.isUnknownDestination());
    flags.set(PCE_UNAVAILABLE, f.isPceUnavailable());
    flags.toByteBuf(body);
    TlvUtil.formatTlv(TYPE, body, buffer);
}
Also used : NoPathVector(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.no.path.tlvs.NoPathVector) BitArray(org.opendaylight.protocol.util.BitArray) Flags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NoPathVectorTlv.Flags) ByteBuf(io.netty.buffer.ByteBuf)

Example 73 with BitArray

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

the class CInitiated00LspObjectParser method parseFlags.

@Override
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));
    builder.addAugmentation(Lsp1.class, new Lsp1Builder().setCreate(flags.get(CREATE_FLAG_OFFSET)).build());
    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 : Lsp1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Lsp1Builder) BitArray(org.opendaylight.protocol.util.BitArray)

Example 74 with BitArray

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

the class CInitiated00SrpObjectParser method serializeFlags.

@Override
protected void serializeFlags(final Srp srp, final ByteBuf body) {
    final BitArray flags = new BitArray(FLAGS_SIZE);
    if (srp.getAugmentation(Srp1.class) != null) {
        flags.set(REMOVE_FLAG, srp.getAugmentation(Srp1.class).isRemove());
    }
    flags.toByteBuf(body);
}
Also used : Srp1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Srp1) BitArray(org.opendaylight.protocol.util.BitArray)

Example 75 with BitArray

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

the class CInitiated00StatefulCapabilityTlvParser method serializeFlags.

@Override
protected BitArray serializeFlags(final Stateful sct) {
    final BitArray flags = new BitArray(FLAGS_F_LENGTH);
    final Stateful1 sfi = sct.getAugmentation(Stateful1.class);
    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)

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