use of org.opendaylight.protocol.util.BitArray in project bgpcep by opendaylight.
the class CInitiated00SrpObjectParser method parseFlags.
@Override
protected void parseFlags(final SrpBuilder builder, final ByteBuf bytes) {
final BitArray flags = BitArray.valueOf(bytes, FLAGS_SIZE);
builder.addAugmentation(Srp1.class, new Srp1Builder().setRemove(flags.get(REMOVE_FLAG)).build());
}
use of org.opendaylight.protocol.util.BitArray in project bgpcep by opendaylight.
the class ProtectionCommonParser method serializeBodyType2.
protected static void serializeBodyType2(final ProtectionSubobject protObj, final ByteBuf output) {
final BitArray flagBitArray = new BitArray(FLAGS_SIZE);
flagBitArray.set(SECONDARY, protObj.isSecondary());
flagBitArray.set(PROTECTING, protObj.isProtecting());
flagBitArray.set(NOTIFICATION, protObj.isNotification());
flagBitArray.set(OPERATIONAL, protObj.isOperational());
flagBitArray.toByteBuf(output);
output.writeByte(protObj.getLspFlag().getIntValue());
output.writeZero(BYTE_SIZE);
output.writeByte(protObj.getLinkFlags().getIntValue());
final BitArray flagInPlaceBitArray = new BitArray(FLAGS_SIZE);
flagInPlaceBitArray.set(IN_PLACE, protObj.isInPlace());
flagInPlaceBitArray.set(REQUIRED, protObj.isRequired());
flagInPlaceBitArray.toByteBuf(output);
output.writeByte(protObj.getSegFlag().getIntValue());
output.writeZero(ByteBufWriteUtil.SHORT_BYTES_LENGTH);
}
use of org.opendaylight.protocol.util.BitArray in project bgpcep by opendaylight.
the class ProtectionCommonParser method serializeBodyType1.
protected static void serializeBodyType1(final ProtectionSubobject protObj, final ByteBuf output) {
final BitArray flagBitArray = new BitArray(FLAGS_SIZE);
flagBitArray.set(SECONDARY, protObj.isSecondary());
flagBitArray.toByteBuf(output);
output.writeZero(ByteBufWriteUtil.SHORT_BYTES_LENGTH);
output.writeByte(protObj.getLinkFlags().getIntValue());
}
use of org.opendaylight.protocol.util.BitArray in project bgpcep by opendaylight.
the class SessionAttributeLspObjectParser method localParseObject.
@Override
protected RsvpTeObject localParseObject(final ByteBuf byteBuf) throws RSVPParsingException {
final BasicSessionAttributeObjectBuilder builder = new BasicSessionAttributeObjectBuilder();
builder.setSetupPriority(byteBuf.readUnsignedByte());
builder.setHoldPriority(byteBuf.readUnsignedByte());
final BitArray bs = BitArray.valueOf(byteBuf.readByte());
builder.setLocalProtectionDesired(bs.get(LOCAL_PROTECTION));
builder.setLabelRecordingDesired(bs.get(LABEL_RECORDING));
builder.setSeStyleDesired(bs.get(SE_STYLE));
final short nameLenght = byteBuf.readUnsignedByte();
final ByteBuf auxBuf = byteBuf.readSlice(nameLenght);
final String name = new String(ByteArray.readAllBytes(auxBuf), StandardCharsets.US_ASCII);
builder.setSessionName(name);
return builder.build();
}
use of org.opendaylight.protocol.util.BitArray in project bgpcep by opendaylight.
the class SessionAttributeLspObjectParser method localSerializeObject.
@Override
public void localSerializeObject(final RsvpTeObject teLspObject, final ByteBuf output) {
Preconditions.checkArgument(teLspObject instanceof BasicSessionAttributeObject, "SessionAttributeObject is mandatory.");
final BasicSessionAttributeObject sessionObject = (BasicSessionAttributeObject) teLspObject;
final ByteBuf sessionName = Unpooled.wrappedBuffer(StandardCharsets.US_ASCII.encode(sessionObject.getSessionName()));
final int pad = getPadding(sessionName.readableBytes());
serializeAttributeHeader(BODY_SIZE_C7 + pad + sessionName.readableBytes(), CLASS_NUM, CTYPE, output);
output.writeByte(sessionObject.getSetupPriority());
output.writeByte(sessionObject.getHoldPriority());
final BitArray bs = new BitArray(FLAGS_SIZE);
bs.set(LOCAL_PROTECTION, sessionObject.isLocalProtectionDesired());
bs.set(LABEL_RECORDING, sessionObject.isLabelRecordingDesired());
bs.set(SE_STYLE, sessionObject.isSeStyleDesired());
bs.toByteBuf(output);
output.writeByte(sessionName.readableBytes());
output.writeBytes(sessionName);
output.writeZero(pad);
}
Aggregations