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);
}
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);
}
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));
}
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);
}
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;
}
Aggregations