Search in sources :

Example 46 with RsvpTeObject

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.RsvpTeObject in project bgpcep by opendaylight.

the class SenderTspecObjectParser method localSerializeObject.

@Override
public void localSerializeObject(final RsvpTeObject teLspObject, final ByteBuf output) {
    Preconditions.checkArgument(teLspObject instanceof TspecObject, "SenderTspecObject is mandatory.");
    final TspecObject tspecObj = (TspecObject) teLspObject;
    serializeAttributeHeader(BODY_SIZE, CLASS_NUM, CTYPE, output);
    output.writeZero(ByteBufWriteUtil.SHORT_BYTES_LENGTH);
    output.writeShort(OVERALL_LENGTH);
    output.writeByte(ByteBufWriteUtil.ONE_BYTE_LENGTH);
    output.writeZero(ByteBufWriteUtil.ONE_BYTE_LENGTH);
    output.writeShort(SERVICE_LENGHT);
    output.writeByte(TOKEN_BUCKET_TSPEC);
    output.writeZero(ByteBufWriteUtil.ONE_BYTE_LENGTH);
    output.writeShort(PARAMETER_127_LENGTH);
    writeFloat32(tspecObj.getTokenBucketRate(), output);
    writeFloat32(tspecObj.getTokenBucketSize(), output);
    writeFloat32(tspecObj.getPeakDataRate(), output);
    writeUnsignedInt(tspecObj.getMinimumPolicedUnit(), output);
    writeUnsignedInt(tspecObj.getMaximumPacketSize(), output);
}
Also used : TspecObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.tspec.object.TspecObject)

Example 47 with RsvpTeObject

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.RsvpTeObject in project bgpcep by opendaylight.

the class SenderTspecObjectParser method localParseObject.

@Override
protected RsvpTeObject localParseObject(final ByteBuf byteBuf) throws RSVPParsingException {
    final TspecObjectBuilder builder = new TspecObjectBuilder();
    // skip version number, reserved, Overall length
    byteBuf.skipBytes(ByteBufWriteUtil.INT_BYTES_LENGTH);
    // skip Service header, reserved, Length of service
    byteBuf.skipBytes(ByteBufWriteUtil.INT_BYTES_LENGTH);
    // skip Parameter ID, Parameter 127 flags, Parameter 127 length
    byteBuf.skipBytes(ByteBufWriteUtil.INT_BYTES_LENGTH);
    builder.setTokenBucketRate(new Float32(ByteArray.readBytes(byteBuf, METRIC_VALUE_F_LENGTH)));
    builder.setTokenBucketSize(new Float32(ByteArray.readBytes(byteBuf, METRIC_VALUE_F_LENGTH)));
    builder.setPeakDataRate(new Float32(ByteArray.readBytes(byteBuf, METRIC_VALUE_F_LENGTH)));
    builder.setMinimumPolicedUnit(byteBuf.readUnsignedInt());
    builder.setMaximumPacketSize(byteBuf.readUnsignedInt());
    return builder.build();
}
Also used : Float32(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32) ByteBufWriteUtil.writeFloat32(org.opendaylight.protocol.util.ByteBufWriteUtil.writeFloat32) TspecObjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.tspec.object.TspecObjectBuilder)

Example 48 with RsvpTeObject

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.RsvpTeObject 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 49 with RsvpTeObject

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.RsvpTeObject 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)

Example 50 with RsvpTeObject

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.RsvpTeObject in project bgpcep by opendaylight.

the class SessionAttributeLspRaObjectParser method localSerializeObject.

@Override
public void localSerializeObject(final RsvpTeObject teLspObject, final ByteBuf output) {
    Preconditions.checkArgument(teLspObject instanceof SessionAttributeObjectWithResourcesAffinities, "SessionAttributeObject is mandatory.");
    final SessionAttributeObjectWithResourcesAffinities sessionObject = (SessionAttributeObjectWithResourcesAffinities) teLspObject;
    final ByteBuf sessionName = Unpooled.wrappedBuffer(StandardCharsets.US_ASCII.encode(sessionObject.getSessionName()));
    final int pad = SessionAttributeLspObjectParser.getPadding(sessionName.readableBytes());
    serializeAttributeHeader(BODY_SIZE_C1 + pad + sessionName.readableBytes(), CLASS_NUM, CTYPE, output);
    writeAttributeFilter(sessionObject.getIncludeAny(), output);
    writeAttributeFilter(sessionObject.getExcludeAny(), output);
    writeAttributeFilter(sessionObject.getIncludeAll(), output);
    output.writeByte(sessionObject.getSetupPriority());
    output.writeByte(sessionObject.getHoldPriority());
    final BitArray bs = new BitArray(FLAGS_SIZE);
    bs.set(SessionAttributeLspObjectParser.LOCAL_PROTECTION, sessionObject.isLocalProtectionDesired());
    bs.set(SessionAttributeLspObjectParser.LABEL_RECORDING, sessionObject.isLabelRecordingDesired());
    bs.set(SessionAttributeLspObjectParser.SE_STYLE, sessionObject.isSeStyleDesired());
    bs.toByteBuf(output);
    output.writeByte(sessionName.readableBytes());
    output.writeBytes(Unpooled.wrappedBuffer(StandardCharsets.US_ASCII.encode(sessionObject.getSessionName())));
    output.writeZero(pad);
}
Also used : SessionAttributeObjectWithResourcesAffinities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.session.attribute.object.session.attribute.object.SessionAttributeObjectWithResourcesAffinities) BitArray(org.opendaylight.protocol.util.BitArray) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)44 Test (org.junit.Test)25 RsvpTeObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.RsvpTeObject)25 BitArray (org.opendaylight.protocol.util.BitArray)8 Bandwidth (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth)6 ArrayList (java.util.ArrayList)4 SubobjectContainer (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.lsp.attributes.object.lsp.attributes.object.SubobjectContainer)4 ByteBufWriteUtil.writeFloat32 (org.opendaylight.protocol.util.ByteBufWriteUtil.writeFloat32)3 Float32 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32)3 AttributeFilter (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.AttributeFilter)3 FlagContainer (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.attribute.flags.FlagContainer)2 Plr (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.detour.object.detour.object.ipv4.detour.object.Plr)2 AvoidNode (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.detour.object.detour.object.ipv6.detour.object.AvoidNode)2 PlrId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.detour.object.detour.object.ipv6.detour.object.PlrId)2 ExplicitRouteObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.object.ExplicitRouteObject)2 LspSubobject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.lsp.att.subobject.LspSubobject)2 FlagsTlv (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.lsp.att.subobject.lsp.subobject.FlagsTlv)2 FlagsTlvBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.lsp.att.subobject.lsp.subobject.FlagsTlvBuilder)2 LspAttributesObjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.lsp.attributes.object.LspAttributesObjectBuilder)2 SubobjectContainerBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.lsp.attributes.object.lsp.attributes.object.SubobjectContainerBuilder)2