Search in sources :

Example 6 with AttributesBuilder

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

the class PMSITunnelAttributeHandler method parseAttribute.

@Override
public void parseAttribute(@Nonnull final ByteBuf buffer, @Nonnull final AttributesBuilder builder) {
    if (!buffer.isReadable()) {
        return;
    }
    final PmsiTunnelBuilder pmsiTunnelBuilder = new PmsiTunnelBuilder();
    pmsiTunnelBuilder.setLeafInformationRequired(buffer.readBoolean());
    final int tunnelType = buffer.readUnsignedByte();
    parseMpls(pmsiTunnelBuilder, buffer);
    final TunnelIdentifier tunnelIdentifier = this.tunnelIdentifierHandler.parse(tunnelType, buffer);
    if (tunnelIdentifier != null) {
        pmsiTunnelBuilder.setTunnelIdentifier(tunnelIdentifier);
    }
    builder.addAugmentation(PmsiTunnelAugmentation.class, new PmsiTunnelAugmentationBuilder().setPmsiTunnel(pmsiTunnelBuilder.build()).build());
}
Also used : PmsiTunnelBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.PmsiTunnelBuilder) TunnelIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.TunnelIdentifier) PmsiTunnelAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.routes.evpn.routes.evpn.route.PmsiTunnelAugmentationBuilder)

Example 7 with AttributesBuilder

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

the class ClusterIdAttributeParser method parseAttribute.

@Override
public void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder) {
    final List<ClusterIdentifier> list = Lists.newArrayList();
    while (buffer.isReadable()) {
        list.add(new ClusterIdentifier(Ipv4Util.addressForByteBuf(buffer)));
    }
    builder.setClusterId(new ClusterIdBuilder().setCluster(list).build());
}
Also used : ClusterIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ClusterIdentifier) ClusterIdBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ClusterIdBuilder)

Example 8 with AttributesBuilder

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

the class ExtendedCommunitiesAttributeParser method parseAttribute.

@Override
public void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder) throws BGPDocumentedException, BGPParsingException {
    final List<ExtendedCommunities> set = new ArrayList<>();
    while (buffer.isReadable()) {
        final ExtendedCommunities exComm = this.ecReg.parseExtendedCommunity(buffer);
        if (exComm != null) {
            set.add(exComm);
        }
    }
    builder.setExtendedCommunities(set);
}
Also used : ExtendedCommunities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ExtendedCommunities) ArrayList(java.util.ArrayList)

Example 9 with AttributesBuilder

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

the class BasePathSelectorTest method createStateFromPrefMedOrigin.

private static Attributes createStateFromPrefMedOrigin() {
    AttributesBuilder dataContBuilder = new AttributesBuilder();
    addLowerLocalRef(dataContBuilder);
    addLowerMultiExitDisc(dataContBuilder);
    addIgpOrigin(dataContBuilder);
    return dataContBuilder.build();
}
Also used : AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)

Example 10 with AttributesBuilder

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

the class BasePathSelectorTest method testBestPathSelectionOptions.

@Test
public void testBestPathSelectionOptions() {
    AttributesBuilder dataContBuilder = createStateFromPrefMedOriginASPath();
    this.selector.processPath(ROUTER_ID2, dataContBuilder.build());
    BaseBestPath processedPath = this.selector.result();
    assertEquals(1, processedPath.getState().getOrigin().getIntValue());
    // prefer the path with the lowest origin type
    addIgpOrigin(dataContBuilder);
    this.selector.processPath(ROUTER_ID2, dataContBuilder.build());
    processedPath = this.selector.result();
    assertEquals(0, processedPath.getState().getOrigin().getIntValue());
    addEgpOrigin(dataContBuilder);
    this.selector.processPath(ROUTER_ID2, dataContBuilder.build());
    processedPath = this.selector.result();
    assertEquals(0, processedPath.getState().getOrigin().getIntValue());
    // prefer the path with the lowest multi-exit discriminator (MED)
    assertEquals(4321L, (long) processedPath.getState().getMultiExitDisc());
    addIgpOrigin(dataContBuilder);
    addLowerMultiExitDisc(dataContBuilder);
    this.selector.processPath(ROUTER_ID2, dataContBuilder.build());
    processedPath = this.selector.result();
    assertEquals(1234L, (long) processedPath.getState().getMultiExitDisc());
    addHigherMultiExitDisc(dataContBuilder);
    this.selector.processPath(ROUTER_ID2, dataContBuilder.build());
    processedPath = this.selector.result();
    assertEquals(1234L, (long) processedPath.getState().getMultiExitDisc());
    addLowerMultiExitDisc(dataContBuilder);
    addAsPath(dataContBuilder, SEQ_SEGMENT2);
    assertEquals(1L, processedPath.getState().getPeerAs());
    assertEquals(3, processedPath.getState().getAsPathLength());
    this.selector.processPath(ROUTER_ID2, dataContBuilder.build());
    processedPath = this.selector.result();
    assertEquals(1L, processedPath.getState().getPeerAs());
    assertEquals(3, processedPath.getState().getAsPathLength());
}
Also used : AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder) Test(org.junit.Test)

Aggregations

AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder)130 Test (org.junit.Test)117 ByteBuf (io.netty.buffer.ByteBuf)69 ArrayList (java.util.ArrayList)40 RouteAttributeContainer (org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer)35 Statement (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement)35 AttributesReachBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesReachBuilder)27 AsPathBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.AsPathBuilder)26 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes)25 AttributesUnreachBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesUnreachBuilder)24 MpReachNlriBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.MpReachNlriBuilder)24 IPV4UNICAST (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST)23 AdvertizedRoutesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.mp.reach.nlri.AdvertizedRoutesBuilder)23 OriginBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.OriginBuilder)20 MpUnreachNlriBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.MpUnreachNlriBuilder)20 UpdateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.UpdateBuilder)19 WithdrawnRoutesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.mp.unreach.nlri.WithdrawnRoutesBuilder)19 Ipv4AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone)18 Ipv4NextHopCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.Ipv4NextHopCaseBuilder)18 LocalPrefBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.LocalPrefBuilder)17