Search in sources :

Example 26 with Attributes1

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1 in project bgpcep by opendaylight.

the class AbstractAddPathTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    this.ribActivator = new RIBActivator();
    this.ribExtension = new SimpleRIBExtensionProviderContext();
    this.ribActivator.startRIBExtensionProvider(this.ribExtension);
    this.bgpActivator = new BGPActivator();
    this.inetActivator = new org.opendaylight.protocol.bgp.inet.BGPActivator();
    this.context = new SimpleBGPExtensionProviderContext();
    this.bgpActivator.start(this.context);
    this.inetActivator.start(this.context);
    this.mappingService = new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(), new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault()))));
    final ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
    moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(BgpParameters.class));
    moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(MultiprotocolCapability.class));
    moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(DestinationIpv4Case.class));
    moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(AdvertizedRoutes.class));
    moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(BgpRib.class));
    moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(Attributes1.class));
    moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(MpReachNlri.class));
    this.mappingService.onGlobalContextUpdated(moduleInfoBackedContext.tryToCreateSchemaContext().get());
    this.schemaContext = moduleInfoBackedContext.getSchemaContext();
    if (!Epoll.isAvailable()) {
        this.worker = new NioEventLoopGroup();
        this.boss = new NioEventLoopGroup();
    }
    this.serverRegistry = new StrictBGPPeerRegistry();
    this.serverDispatcher = new BGPDispatcherImpl(this.context.getMessageRegistry(), this.boss, this.worker, this.serverRegistry);
    doReturn(Mockito.mock(ClusterSingletonServiceRegistration.class)).when(this.clusterSingletonServiceProvider).registerClusterSingletonService(any(ClusterSingletonService.class));
    this.codecsRegistry = CodecsRegistryImpl.create(this.mappingService.getCodecFactory(), this.ribExtension.getClassLoadingStrategy());
}
Also used : RIBActivator(org.opendaylight.protocol.bgp.inet.RIBActivator) BGPActivator(org.opendaylight.protocol.bgp.parser.impl.BGPActivator) AdvertizedRoutes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.reach.nlri.AdvertizedRoutes) BindingToNormalizedNodeCodec(org.opendaylight.mdsal.binding.dom.adapter.BindingToNormalizedNodeCodec) BindingNormalizedNodeCodecRegistry(org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry) Attributes1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1) BgpParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters) ModuleInfoBackedContext(org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext) SimpleRIBExtensionProviderContext(org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContext) SimpleBGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext) MultiprotocolCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.MultiprotocolCapability) ClusterSingletonServiceRegistration(org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration) ClusterSingletonService(org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService) MpReachNlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlri) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) DestinationIpv4Case(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv4Case) BgpRib(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.BgpRib) Before(org.junit.Before)

Example 27 with Attributes1

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1 in project bgpcep by opendaylight.

the class SynchronizationTest method setUp.

@Before
public void setUp() {
    this.listener = new SimpleSessionListener();
    this.ipv4m = new UpdateBuilder().setNlri(Collections.singletonList(new NlriBuilder().setPrefix(new Ipv4Prefix("1.1.1.1/32")).build())).build();
    MpReachNlriBuilder mpBuilder = new MpReachNlriBuilder();
    mpBuilder.setAfi(Ipv6AddressFamily.class);
    mpBuilder.setSafi(UnicastSubsequentAddressFamily.class);
    AttributesBuilder paBuilder = new AttributesBuilder().addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(mpBuilder.build()).build());
    this.ipv6m = new UpdateBuilder().setAttributes(paBuilder.build()).build();
    mpBuilder = new MpReachNlriBuilder();
    mpBuilder.setAfi(LinkstateAddressFamily.class);
    mpBuilder.setSafi(LinkstateSubsequentAddressFamily.class);
    paBuilder = new AttributesBuilder().addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(mpBuilder.build()).build());
    this.lsm = new UpdateBuilder().setAttributes(paBuilder.build()).build();
    this.eorm = new UpdateBuilder().build();
    this.bs = new BGPSynchronization(this.listener, Sets.newHashSet(this.ipv4, this.linkstate));
}
Also used : MpReachNlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlriBuilder) Attributes1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1Builder) UpdateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.UpdateBuilder) Attributes1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1) MpReachNlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlriBuilder) NlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.update.message.NlriBuilder) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder) Before(org.junit.Before)

Example 28 with Attributes1

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1 in project bgpcep by opendaylight.

the class BGPSynchronization method updReceived.

/**
 * For each received Update message, the upd sync variable needs to be updated to true, for particular AFI/SAFI
 * combination. Currently we only assume Unicast SAFI. From the Update message we have to extract the AFI. Each
 * Update message can contain BGP Object with one type of AFI. If the object is BGP Link, BGP Node or a BGPPrefix
 * the AFI is Linkstate. In case of BGPRoute, the AFI depends on the IP Address of the prefix.
 *
 * @param msg received Update message
 */
public void updReceived(final Update msg) {
    TablesKey type = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
    boolean isEOR = false;
    if (msg.getNlri() == null && msg.getWithdrawnRoutes() == null) {
        if (msg.getAttributes() != null) {
            if (msg.getAttributes().getAugmentation(Attributes1.class) != null) {
                final Attributes1 pa = msg.getAttributes().getAugmentation(Attributes1.class);
                if (pa.getMpReachNlri() != null) {
                    type = new TablesKey(pa.getMpReachNlri().getAfi(), pa.getMpReachNlri().getSafi());
                }
            } else if (msg.getAttributes().getAugmentation(Attributes2.class) != null) {
                final Attributes2 pa = msg.getAttributes().getAugmentation(Attributes2.class);
                if (pa.getMpUnreachNlri() != null) {
                    type = new TablesKey(pa.getMpUnreachNlri().getAfi(), pa.getMpUnreachNlri().getSafi());
                }
                if (pa.getMpUnreachNlri().getWithdrawnRoutes() == null) {
                    // EOR message contains only MPUnreach attribute and no NLRI
                    isEOR = true;
                }
            }
        } else {
            // true for empty Update Message
            isEOR = true;
        }
    }
    syncType(type, isEOR);
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) Attributes2(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes2) Attributes1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1)

Example 29 with Attributes1

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1 in project bgpcep by opendaylight.

the class CodecsImpl method serializeAttributes.

@Override
public ContainerNode serializeAttributes(final Attributes pathAttr) {
    Preconditions.checkState(this.attributesCodec != null, "Attributes codec not available");
    final AttributesBuilder a = new AttributesBuilder(pathAttr);
    a.addAugmentation(Attributes1.class, null);
    a.addAugmentation(Attributes2.class, null);
    return (ContainerNode) this.attributesCodec.serialize(a.build());
}
Also used : ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)

Example 30 with Attributes1

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1 in project bgpcep by opendaylight.

the class AbstractRIBSupport method buildUpdate.

@Nonnull
@Override
public final Update buildUpdate(final Collection<MapEntryNode> advertised, final Collection<MapEntryNode> withdrawn, final Attributes attr) {
    final UpdateBuilder ub = new UpdateBuilder();
    final AttributesBuilder ab = new AttributesBuilder(attr);
    final CNextHop hop = ab.getCNextHop();
    LOG.debug("cnextHop before={}", hop);
    // do not preserve next hop in attributes if we are using MpReach
    ab.setCNextHop(null);
    if (!advertised.isEmpty()) {
        final MpReachNlri mb = buildReach(advertised, hop);
        ab.addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(mb).build());
        LOG.debug("mpreach nexthop={}", mb);
    }
    if (!withdrawn.isEmpty()) {
        final MpUnreachNlri mb = buildUnreach(withdrawn);
        ab.addAugmentation(Attributes2.class, new Attributes2Builder().setMpUnreachNlri(mb).build());
        LOG.debug("mpunrach mb={}", mb);
    }
    ub.setAttributes(ab.build());
    LOG.debug("update {}", ub.build());
    return ub.build();
}
Also used : Attributes1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1Builder) Attributes2Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes2Builder) MpUnreachNlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpUnreachNlri) UpdateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.UpdateBuilder) CNextHop(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.CNextHop) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder) MpReachNlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlri) Nonnull(javax.annotation.Nonnull)

Aggregations

Test (org.junit.Test)50 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)32 Attributes1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1)32 Attributes1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1Builder)28 ByteBuf (io.netty.buffer.ByteBuf)27 Update (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update)27 Attributes2 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes2)25 MpReachNlriBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlriBuilder)25 AbstractRIBSupportTest (org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupportTest)24 AdvertizedRoutesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.reach.nlri.AdvertizedRoutesBuilder)24 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)16 MpReachNlri (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlri)15 ArrayList (java.util.ArrayList)11 AdvertizedRoutes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.reach.nlri.AdvertizedRoutes)10 Flowspec (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.Flowspec)8 FlowspecBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.FlowspecBuilder)8 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)7 Attributes1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Attributes1)7 Ipv6Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix)6 WithdrawnRoutes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.unreach.nlri.WithdrawnRoutes)6