Search in sources :

Example 1 with NlriSerializer

use of org.opendaylight.protocol.bgp.parser.spi.NlriSerializer in project bgpcep by opendaylight.

the class MPReachAttributeParser method serializeAttribute.

@Override
public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
    Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object.");
    final Attributes pathAttributes = (Attributes) attribute;
    final Attributes1 pathAttributes1 = pathAttributes.getAugmentation(Attributes1.class);
    if (pathAttributes1 == null) {
        return;
    }
    final MpReachNlri mpReachNlri = pathAttributes1.getMpReachNlri();
    final ByteBuf reachBuffer = Unpooled.buffer();
    this.reg.serializeMpReach(mpReachNlri, reachBuffer);
    for (final NlriSerializer nlriSerializer : this.reg.getSerializers()) {
        nlriSerializer.serializeAttribute(attribute, reachBuffer);
    }
    AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL, TYPE, reachBuffer, byteAggregator);
}
Also used : NlriSerializer(org.opendaylight.protocol.bgp.parser.spi.NlriSerializer) Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes) Attributes1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1) ByteBuf(io.netty.buffer.ByteBuf) MpReachNlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlri)

Example 2 with NlriSerializer

use of org.opendaylight.protocol.bgp.parser.spi.NlriSerializer in project bgpcep by opendaylight.

the class SimpleNlriRegistry method registerNlriSerializer.

synchronized AutoCloseable registerNlriSerializer(final Class<? extends DataObject> nlriClass, final NlriSerializer serializer) {
    final NlriSerializer prev = this.serializers.get(nlriClass);
    Preconditions.checkState(prev == null, "Serializer already bound to class " + prev);
    this.serializers.put(nlriClass, serializer);
    final Object lock = this;
    return new AbstractRegistration() {

        @Override
        protected void removeRegistration() {
            synchronized (lock) {
                SimpleNlriRegistry.this.serializers.remove(nlriClass);
            }
        }
    };
}
Also used : AbstractRegistration(org.opendaylight.protocol.concepts.AbstractRegistration) NlriSerializer(org.opendaylight.protocol.bgp.parser.spi.NlriSerializer) DataObject(org.opendaylight.yangtools.yang.binding.DataObject)

Example 3 with NlriSerializer

use of org.opendaylight.protocol.bgp.parser.spi.NlriSerializer in project bgpcep by opendaylight.

the class MPUnreachAttributeParser method serializeAttribute.

@Override
public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
    Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object.");
    final Attributes pathAttributes = (Attributes) attribute;
    final Attributes2 pathAttributes2 = pathAttributes.getAugmentation(Attributes2.class);
    if (pathAttributes2 == null) {
        return;
    }
    final MpUnreachNlri mpUnreachNlri = pathAttributes2.getMpUnreachNlri();
    final ByteBuf unreachBuffer = Unpooled.buffer();
    this.reg.serializeMpUnReach(mpUnreachNlri, unreachBuffer);
    for (final NlriSerializer nlriSerializer : this.reg.getSerializers()) {
        nlriSerializer.serializeAttribute(attribute, unreachBuffer);
    }
    AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL, TYPE, unreachBuffer, byteAggregator);
}
Also used : MpUnreachNlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpUnreachNlri) NlriSerializer(org.opendaylight.protocol.bgp.parser.spi.NlriSerializer) Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes) Attributes2(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes2) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

NlriSerializer (org.opendaylight.protocol.bgp.parser.spi.NlriSerializer)3 ByteBuf (io.netty.buffer.ByteBuf)2 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)2 AbstractRegistration (org.opendaylight.protocol.concepts.AbstractRegistration)1 Attributes1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1)1 Attributes2 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes2)1 MpReachNlri (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlri)1 MpUnreachNlri (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpUnreachNlri)1 DataObject (org.opendaylight.yangtools.yang.binding.DataObject)1