Search in sources :

Example 96 with Attributes

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes in project bgpcep by opendaylight.

the class UnrecognizedAttributesSerializer method serializeAttribute.

@Override
public void serializeAttribute(final Attributes attributes, final ByteBuf byteAggregator) {
    final Map<UnrecognizedAttributesKey, UnrecognizedAttributes> unrecognizedAttrs = attributes.getUnrecognizedAttributes();
    if (unrecognizedAttrs == null) {
        return;
    }
    for (final UnrecognizedAttributes unrecognizedAttr : unrecognizedAttrs.values()) {
        LOG.trace("Serializing unrecognized attribute of type {}", unrecognizedAttr.getType());
        int flags = AttributeUtil.OPTIONAL;
        if (unrecognizedAttr.getPartial()) {
            flags |= AttributeUtil.PARTIAL;
        }
        if (unrecognizedAttr.getTransitive()) {
            flags |= AttributeUtil.TRANSITIVE;
        }
        AttributeUtil.formatAttribute(flags, unrecognizedAttr.getType().toJava(), Unpooled.wrappedBuffer(unrecognizedAttr.getValue()), byteAggregator);
    }
}
Also used : UnrecognizedAttributesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.UnrecognizedAttributesKey) UnrecognizedAttributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.UnrecognizedAttributes)

Example 97 with Attributes

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes in project bgpcep by opendaylight.

the class ClusterIdAttributeParser method serializeAttribute.

@Override
public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) {
    final ClusterId cid = pathAttributes.getClusterId();
    if (cid != null) {
        final List<ClusterIdentifier> cluster = cid.getCluster();
        if (cluster != null && !cluster.isEmpty()) {
            final ByteBuf clusterIdBuffer = Unpooled.buffer();
            for (final ClusterIdentifier clusterIdentifier : cluster) {
                clusterIdBuffer.writeBytes(Ipv4Util.bytesForAddress(clusterIdentifier));
            }
            AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL, TYPE, clusterIdBuffer, byteAggregator);
        }
    }
}
Also used : ClusterId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ClusterId) ClusterIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.ClusterIdentifier) ByteBuf(io.netty.buffer.ByteBuf)

Example 98 with Attributes

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes in project bgpcep by opendaylight.

the class MPUnreachAttributeParser method serializeAttribute.

@Override
public void serializeAttribute(final Attributes attribute, final ByteBuf byteAggregator) {
    final AttributesUnreach pathAttributes2 = attribute.augmentation(AttributesUnreach.class);
    if (pathAttributes2 != null) {
        final ByteBuf unreachBuffer = Unpooled.buffer();
        reg.serializeMpUnReach(pathAttributes2.getMpUnreachNlri(), unreachBuffer);
        for (final NlriSerializer nlriSerializer : this.reg.getSerializers()) {
            nlriSerializer.serializeAttribute(attribute, unreachBuffer);
        }
        AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL, TYPE, unreachBuffer, byteAggregator);
    }
}
Also used : NlriSerializer(org.opendaylight.protocol.bgp.parser.spi.NlriSerializer) AttributesUnreach(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesUnreach) ByteBuf(io.netty.buffer.ByteBuf)

Example 99 with Attributes

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes in project bgpcep by opendaylight.

the class NextHopAttributeParser method serializeAttribute.

@Override
public void serializeAttribute(final Attributes attribute, final ByteBuf byteAggregator) {
    final CNextHop cNextHop = attribute.getCNextHop();
    if (cNextHop != null) {
        final ByteBuf nextHopBuffer = Unpooled.buffer();
        NextHopUtil.serializeNextHop(cNextHop, nextHopBuffer);
        AttributeUtil.formatAttribute(AttributeUtil.TRANSITIVE, TYPE, nextHopBuffer, byteAggregator);
    }
}
Also used : CNextHop(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.CNextHop) ByteBuf(io.netty.buffer.ByteBuf)

Example 100 with Attributes

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes in project bgpcep by opendaylight.

the class BGPUpdateMessageParser method checkMandatoryAttributesPresence.

/**
 * Check for presence of well known mandatory path attributes ORIGIN, AS_PATH and NEXT_HOP in Update message.
 *
 * @param message Update message
 * @param errorHandling Error handling type
 */
private static void checkMandatoryAttributesPresence(final Update message, final RevisedErrorHandling errorHandling) throws BGPDocumentedException, BGPTreatAsWithdrawException {
    requireNonNull(message, "Update message cannot be null");
    final Attributes attrs = message.getAttributes();
    if (message.getNlri() != null && (attrs == null || attrs.getCNextHop() == null)) {
        throw reportMissingAttribute(errorHandling, "NEXT_HOP", NextHopAttributeParser.TYPE);
    }
    if (MessageUtil.isAnyNlriPresent(message)) {
        if (attrs == null || attrs.getOrigin() == null) {
            throw reportMissingAttribute(errorHandling, "ORIGIN", OriginAttributeParser.TYPE);
        }
        if (attrs.getAsPath() == null) {
            throw reportMissingAttribute(errorHandling, "AS_PATH", AsPathAttributeParser.TYPE);
        }
    }
}
Also used : Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes) ParsedAttributes(org.opendaylight.protocol.bgp.parser.spi.ParsedAttributes)

Aggregations

Test (org.junit.Test)104 ByteBuf (io.netty.buffer.ByteBuf)82 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes)60 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)47 Update (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update)47 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder)42 AbstractRIBSupportTest (org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupportTest)38 AttributesReach (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesReach)35 AttributesUnreach (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesUnreach)35 ArrayList (java.util.ArrayList)31 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)14 Ipv4AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone)13 UpdateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.UpdateBuilder)13 Ipv4NextHopCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.Ipv4NextHopCaseBuilder)12 Ipv4NextHopBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder)12 PmsiTunnelBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.pmsi.tunnel.PmsiTunnelBuilder)12 Collections (java.util.Collections)11 AsPathBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.AsPathBuilder)11 MpUnreachNlri (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.MpUnreachNlri)11 AsNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)10