Search in sources :

Example 46 with BitArray

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());
}
Also used : Srp1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Srp1Builder) BitArray(org.opendaylight.protocol.util.BitArray)

Example 47 with BitArray

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);
}
Also used : BitArray(org.opendaylight.protocol.util.BitArray)

Example 48 with BitArray

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());
}
Also used : BitArray(org.opendaylight.protocol.util.BitArray)

Example 49 with BitArray

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();
}
Also used : BitArray(org.opendaylight.protocol.util.BitArray) ByteBuf(io.netty.buffer.ByteBuf) BasicSessionAttributeObjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.session.attribute.object.session.attribute.object.BasicSessionAttributeObjectBuilder)

Example 50 with BitArray

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);
}
Also used : BasicSessionAttributeObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.session.attribute.object.session.attribute.object.BasicSessionAttributeObject) BitArray(org.opendaylight.protocol.util.BitArray) ByteBuf(io.netty.buffer.ByteBuf)

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