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