Search in sources :

Example 1 with FlagContainer

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

the class AttributesObjectParser method localSerializeObject.

@Override
public void localSerializeObject(final RsvpTeObject teLspObject, final ByteBuf byteAggregator) {
    Preconditions.checkArgument(teLspObject instanceof LspAttributesObject, "LspAttributesObject is mandatory.");
    final LspAttributesObject lspAttributesObject = (LspAttributesObject) teLspObject;
    final ByteBuf bufferAux = Unpooled.buffer();
    int length = 0;
    for (final SubobjectContainer subObject : lspAttributesObject.getSubobjectContainer()) {
        final LspSubobject lspSubonject = subObject.getLspSubobject();
        if (lspSubonject instanceof FlagsTlv) {
            final ByteBuf flagTLVValue = Unpooled.buffer();
            final List<FlagContainer> flagList = ((FlagsTlv) lspSubonject).getFlagContainer();
            length = FLAG_TLV_SIZE * flagList.size();
            serializeFlag(flagList, flagTLVValue);
            serializeTLV(FLAG_TLV_TYPE, length, flagTLVValue, bufferAux);
            length += TLV_HEADER_SIZE;
        }
    }
    serializeAttributeHeader(length, CLASS_NUM, CTYPE, byteAggregator);
    byteAggregator.writeBytes(bufferAux);
}
Also used : SubobjectContainer(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.lsp.attributes.object.lsp.attributes.object.SubobjectContainer) LspSubobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.lsp.att.subobject.LspSubobject) FlagContainer(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.attribute.flags.FlagContainer) ByteBuf(io.netty.buffer.ByteBuf) FlagsTlv(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.lsp.att.subobject.lsp.subobject.FlagsTlv) LspAttributesObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.lsp.attributes.object.LspAttributesObject)

Example 2 with FlagContainer

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

the class RequiredAttributesObjectParser method localSerializeObject.

@Override
public void localSerializeObject(final RsvpTeObject teLspObject, final ByteBuf byteAggregator) {
    Preconditions.checkArgument(teLspObject instanceof LspRequiredAttributesObject, "LspAttributesObject is mandatory.");
    final LspRequiredAttributesObject lspAttributesObject = (LspRequiredAttributesObject) teLspObject;
    final ByteBuf bufferAux = Unpooled.buffer();
    int lenght = 0;
    for (final SubobjectContainer subObject : lspAttributesObject.getLspAttributesObject().getSubobjectContainer()) {
        final LspSubobject lspSubonject = subObject.getLspSubobject();
        if (lspSubonject instanceof FlagsTlv) {
            final ByteBuf flagTLVValue = Unpooled.buffer();
            final List<FlagContainer> flagList = ((FlagsTlv) lspSubonject).getFlagContainer();
            lenght = AttributesObjectParser.FLAG_TLV_SIZE * flagList.size();
            AttributesObjectParser.serializeFlag(flagList, flagTLVValue);
            AttributesObjectParser.serializeTLV(AttributesObjectParser.FLAG_TLV_TYPE, lenght, flagTLVValue, bufferAux);
            lenght += AttributesObjectParser.TLV_HEADER_SIZE;
        }
    }
    serializeAttributeHeader(lenght, CLASS_NUM, CTYPE, byteAggregator);
    byteAggregator.writeBytes(bufferAux);
}
Also used : SubobjectContainer(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.lsp.attributes.object.lsp.attributes.object.SubobjectContainer) LspSubobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.lsp.att.subobject.LspSubobject) FlagContainer(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.attribute.flags.FlagContainer) ByteBuf(io.netty.buffer.ByteBuf) FlagsTlv(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.lsp.att.subobject.lsp.subobject.FlagsTlv) LspRequiredAttributesObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.lsp.required.attributes.object.LspRequiredAttributesObject)

Example 3 with FlagContainer

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

the class AttributesObjectParser method parseFlag.

static List<FlagContainer> parseFlag(final ByteBuf byteBuf) {
    final List<FlagContainer> flagList = new ArrayList<>();
    while (byteBuf.isReadable()) {
        final byte[] value = ByteArray.readBytes(byteBuf, FLAG_TLV_SIZE);
        final FlagContainerBuilder flagBuilder = new FlagContainerBuilder().setFlags(value);
        flagList.add(flagBuilder.build());
    }
    return flagList;
}
Also used : FlagContainer(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.attribute.flags.FlagContainer) ArrayList(java.util.ArrayList) FlagContainerBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.attribute.flags.FlagContainerBuilder)

Aggregations

FlagContainer (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.attribute.flags.FlagContainer)3 ByteBuf (io.netty.buffer.ByteBuf)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 SubobjectContainer (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.lsp.attributes.object.lsp.attributes.object.SubobjectContainer)2 ArrayList (java.util.ArrayList)1 FlagContainerBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.attribute.flags.FlagContainerBuilder)1 LspAttributesObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.lsp.attributes.object.LspAttributesObject)1 LspRequiredAttributesObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.lsp.required.attributes.object.LspRequiredAttributesObject)1