Search in sources :

Example 1 with BgpId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpId in project bgpcep by opendaylight.

the class TestUtil method createRouteMirrorMsg.

public static RouteMirroringMessage createRouteMirrorMsg(final Ipv4Address bgpId) {
    final RouteMirroringMessageBuilder routeMirrorMsgBuilder = new RouteMirroringMessageBuilder().setPeerHeader(createPeerHeader(bgpId));
    final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.mirror.TlvsBuilder tlvsBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.mirror.TlvsBuilder();
    tlvsBuilder.setMirrorInformationTlv(new MirrorInformationTlvBuilder().setCode(MirrorInformationCode.forValue(1)).build());
    routeMirrorMsgBuilder.setTlvs(tlvsBuilder.build());
    return routeMirrorMsgBuilder.build();
}
Also used : TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.initiation.TlvsBuilder) RouteMirroringMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.RouteMirroringMessageBuilder) MirrorInformationTlvBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.mirror.information.tlv.MirrorInformationTlvBuilder)

Example 2 with BgpId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpId in project bgpcep by opendaylight.

the class AbstractAddPathTest method configurePeer.

protected static BGPPeer configurePeer(final Ipv4Address peerAddress, final RIBImpl ribImpl, final BgpParameters bgpParameters, final PeerRole peerRole, final BGPPeerRegistry bgpPeerRegistry) {
    final IpAddress ipAddress = new IpAddress(peerAddress);
    final BGPPeer bgpPeer = new BGPPeer(new IpAddress(peerAddress), ribImpl, peerRole, null, AFI_SAFIS_ADVERTIZED, Collections.emptySet());
    final List<BgpParameters> tlvs = Lists.newArrayList(bgpParameters);
    bgpPeerRegistry.addPeer(ipAddress, bgpPeer, new BGPSessionPreferences(AS_NUMBER, HOLDTIMER, new BgpId(RIB_ID), AS_NUMBER, tlvs));
    bgpPeer.instantiateServiceInstance();
    return bgpPeer;
}
Also used : BGPSessionPreferences(org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences) BgpId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpId) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) BgpParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters)

Example 3 with BgpId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpId in project bgpcep by opendaylight.

the class SynchronizationAndExceptionTest method testUseCase1.

@Test
public void testUseCase1() {
    final Map<TablesKey, PathSelectionMode> pathTables = ImmutableMap.of(TABLES_KEY, BasePathSelectionModeFactory.createBestPathSelectionStrategy(this.peerTracker));
    final RIBImpl ribImpl = new RIBImpl(new RibId(RIB_ID), AS_NUMBER, new BgpId(RIB_ID), this.ribExtension, this.serverDispatcher, this.codecsRegistry, this.domBroker, getDataBroker(), this.policies, this.peerTracker, ImmutableList.of(this.ipv4tt), pathTables);
    ribImpl.instantiateServiceInstance();
    ribImpl.onGlobalContextUpdated(this.schemaContext);
    final BGPPeer bgpPeer = new BGPPeer(neighbor, ribImpl, PeerRole.Ibgp, null, AFI_SAFIS_ADVERTIZED, Collections.emptySet());
    bgpPeer.instantiateServiceInstance();
    final BGPSessionImpl bgpSession = new BGPSessionImpl(bgpPeer, this.speakerListener, this.classicOpen, this.classicOpen.getHoldTimer(), null);
    bgpSession.setChannelExtMsgCoder(this.classicOpen);
    bgpPeer.onSessionUp(bgpSession);
    final Nlri n1 = new NlriBuilder().setPrefix(new Ipv4Prefix("8.0.1.0/28")).build();
    final Nlri n2 = new NlriBuilder().setPrefix(new Ipv4Prefix("127.0.0.1/32")).build();
    final Nlri n3 = new NlriBuilder().setPrefix(new Ipv4Prefix("2.2.2.2/24")).build();
    final List<Nlri> nlris = Lists.newArrayList(n1, n2, n3);
    final UpdateBuilder wrongMessage = new UpdateBuilder();
    wrongMessage.setNlri(nlris);
    final Origin origin = new OriginBuilder().setValue(BgpOrigin.Igp).build();
    final AsPath asPath = new AsPathBuilder().setSegments(Collections.emptyList()).build();
    final CNextHop nextHop = new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("127.0.0.1")).build()).build();
    final AttributesBuilder ab = new AttributesBuilder();
    wrongMessage.setAttributes(ab.setOrigin(origin).setAsPath(asPath).setCNextHop(nextHop).build());
    final UpdateBuilder correct = new UpdateBuilder(wrongMessage.build());
    correct.setAttributes(ab.setLocalPref(new LocalPrefBuilder().setPref((long) 100).build()).build());
    bgpSession.handleMessage(correct.build());
    verify(this.tx, times(2)).merge(eq(LogicalDatastoreType.OPERATIONAL), any(YangInstanceIdentifier.class), any(NormalizedNode.class));
    bgpSession.handleMessage(new UpdateBuilder().build());
    verify(this.tx, times(3)).merge(eq(LogicalDatastoreType.OPERATIONAL), any(YangInstanceIdentifier.class), any(NormalizedNode.class));
    verify(this.tx).merge(eq(LogicalDatastoreType.OPERATIONAL), eq(TABLE_PATH), eq(ImmutableNodes.leafNode(ATTRIBUTES_UPTODATE_FALSE.getNodeType(), Boolean.TRUE)));
    verify(this.tx, times(0)).delete(eq(LogicalDatastoreType.OPERATIONAL), eq(PEER_PATH));
}
Also used : BgpOrigin(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpOrigin) Origin(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.Origin) LocalPrefBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.LocalPrefBuilder) OriginBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.OriginBuilder) UpdateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.UpdateBuilder) RibId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.RibId) AsPathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.AsPathBuilder) Ipv4NextHopCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv4NextHopCaseBuilder) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) CNextHop(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.CNextHop) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Nlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.update.message.Nlri) AsPath(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.AsPath) Ipv4NextHopBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder) BgpId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpId) PathSelectionMode(org.opendaylight.protocol.bgp.mode.api.PathSelectionMode) NlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.update.message.NlriBuilder) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder) Test(org.junit.Test)

Example 4 with BgpId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpId in project bgpcep by opendaylight.

the class RibImpl method createRib.

private RIBImpl createRib(final Global global, final String bgpInstanceName, final BGPTableTypeRegistryConsumer tableTypeRegistry) {
    this.afiSafi = getAfiSafiWithDefault(global.getAfiSafis(), true);
    final Config globalConfig = global.getConfig();
    this.asNumber = globalConfig.getAs();
    this.routerId = globalConfig.getRouterId();
    this.clusterId = getGlobalClusterIdentifier(globalConfig);
    final BGPPeerTrackerImpl peerTracker = new BGPPeerTrackerImpl();
    final Map<TablesKey, PathSelectionMode> pathSelectionModes = OpenConfigMappingUtil.toPathSelectionMode(this.afiSafi, tableTypeRegistry, peerTracker).entrySet().stream().collect(Collectors.toMap(entry -> new TablesKey(entry.getKey().getAfi(), entry.getKey().getSafi()), Map.Entry::getValue));
    final BGPRibRoutingPolicy ribPolicy = this.policyProvider.buildBGPRibPolicy(this.asNumber.getValue(), this.routerId, this.clusterId, RoutingPolicyUtil.getApplyPolicy(global.getApplyPolicy()));
    final CodecsRegistryImpl codecsRegistry = CodecsRegistryImpl.create(codecTreeFactory, this.extensions.getClassLoadingStrategy());
    return new RIBImpl(new RibId(bgpInstanceName), this.asNumber, new BgpId(this.routerId), this.extensions, this.dispatcher, codecsRegistry, this.domBroker, this.dataBroker, ribPolicy, peerTracker, toTableTypes(this.afiSafi, tableTypeRegistry), pathSelectionModes);
}
Also used : OpenConfigMappingUtil.getGlobalClusterIdentifier(org.opendaylight.protocol.bgp.rib.impl.config.OpenConfigMappingUtil.getGlobalClusterIdentifier) LoggerFactory(org.slf4j.LoggerFactory) ListenerRegistration(org.opendaylight.yangtools.concepts.ListenerRegistration) BGPDispatcher(org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher) Rib(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.Rib) TransactionChainListener(org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener) Map(java.util.Map) AfiSafi(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi) RIBImpl(org.opendaylight.protocol.bgp.rib.impl.RIBImpl) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) OpenConfigMappingUtil.toTableTypes(org.opendaylight.protocol.bgp.rib.impl.config.OpenConfigMappingUtil.toTableTypes) BindingTransactionChain(org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain) DOMTransactionChain(org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain) DOMDataTreeChangeService(org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) RibId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.RibId) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) Set(java.util.Set) Collectors(java.util.stream.Collectors) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) List(java.util.List) BgpId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpId) DOMDataBroker(org.opendaylight.controller.md.sal.dom.api.DOMDataBroker) BGPRibRoutingPolicyFactory(org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.BGPRibRoutingPolicyFactory) DOMSchemaService(org.opendaylight.mdsal.dom.api.DOMSchemaService) SchemaContextListener(org.opendaylight.yangtools.yang.model.api.SchemaContextListener) RIB(org.opendaylight.protocol.bgp.rib.impl.spi.RIB) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Config(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.Config) BGPRibRoutingPolicy(org.opendaylight.protocol.bgp.rib.spi.policy.BGPRibRoutingPolicy) RIBSupportContextRegistry(org.opendaylight.protocol.bgp.rib.impl.spi.RIBSupportContextRegistry) CodecsRegistry(org.opendaylight.protocol.bgp.rib.impl.spi.CodecsRegistry) BGPPeerTracker(org.opendaylight.protocol.bgp.rib.spi.BGPPeerTracker) ServiceRegistration(org.osgi.framework.ServiceRegistration) Global(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Global) Logger(org.slf4j.Logger) BGPRibState(org.opendaylight.protocol.bgp.rib.spi.state.BGPRibState) RibKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.RibKey) PathSelectionMode(org.opendaylight.protocol.bgp.mode.api.PathSelectionMode) BindingCodecTreeFactory(org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTreeFactory) BGPPeerTrackerImpl(org.opendaylight.protocol.bgp.rib.impl.BGPPeerTrackerImpl) Futures(com.google.common.util.concurrent.Futures) BGPRibStateConsumer(org.opendaylight.protocol.bgp.rib.spi.state.BGPRibStateConsumer) BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType) OpenConfigMappingUtil.getAfiSafiWithDefault(org.opendaylight.protocol.bgp.rib.impl.config.OpenConfigMappingUtil.getAfiSafiWithDefault) AsNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) BGPTableTypeRegistryConsumer(org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer) Preconditions(com.google.common.base.Preconditions) ClusterIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ClusterIdentifier) CodecsRegistryImpl(org.opendaylight.protocol.bgp.rib.impl.CodecsRegistryImpl) RIBExtensionConsumerContext(org.opendaylight.protocol.bgp.rib.spi.RIBExtensionConsumerContext) BGPRibRoutingPolicy(org.opendaylight.protocol.bgp.rib.spi.policy.BGPRibRoutingPolicy) RibId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.RibId) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) BgpId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpId) CodecsRegistryImpl(org.opendaylight.protocol.bgp.rib.impl.CodecsRegistryImpl) Config(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.Config) BGPPeerTrackerImpl(org.opendaylight.protocol.bgp.rib.impl.BGPPeerTrackerImpl) PathSelectionMode(org.opendaylight.protocol.bgp.mode.api.PathSelectionMode) Map(java.util.Map) RIBImpl(org.opendaylight.protocol.bgp.rib.impl.RIBImpl)

Example 5 with BgpId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpId in project bgpcep by opendaylight.

the class ParserTest method testBGPNode.

/*
     * TEST BGP Node
     *
     *  00 00 <- withdrawn routes length
        00 b1 <- total path attribute length (177)
        80 <- attribute flags
        0e <- attribute type code (MP reach)
        a0 <- attribute length (160)
        40 04 <- AFI (16388 - Linkstate)
        47 <- SAFI (71 - Linkstate)
        04 <- next hop length
        19 19 19 01 - nexthop (25.25.25.1)
        00 <- reserved

        00 01 <- NLRI type (1 - nodeNLRI)
        00 31 <- NLRI length (49)
        03 <- ProtocolID - OSPF
        00 00 00 00 00 00 00 01 <- identifier
        01 00 <- local node descriptor type (256)
        00 24 <- length (36)
        02 00 <- node descriptor type (member AS - 512)
        00 04 <- length
        00 00 00 64 <- value (100)
        02 01 <- node descriptor type (bgpId - 513)
        00 04 <- length
        19 19 19 01 <- bgpId (25.25.25.1)
        02 02 <- node descriptor type (areaId - 514)
        00 04 <- length
        00 00 00 00 <- value
        02 03 <- node descriptor type (routeId - 515)
        00 08 <- length
        03 03 03 04 0b 0b 0b 03 <- OSPF Router Id

        00 01 <- NLRI type (1 - nodeNLRI)
        00 2d <- NLRI length (45)
        03 <- ProtocolID - OSPF
        00 00 00 00 00 00 00 01 <- identifier
        01 00 <- local node descriptor type (256)
        00 20 <- length (32)
        02 00 <- node descriptor type (member AS - 512)
        00 04 <- length
        00 00 00 64 <- value (100)
        02 01 <- node descriptor type (bgpId - 513)
        00 04 <- length
        19 19 19 01 <- bgpId (25.25.25.1)
        02 02 <- node descriptor type (areaId - 514)
        00 04 <- length
        00 00 00 00 <- value
        02 03 <- node descriptor type (routeId - 515)
        00 04 <- length
        03 03 03 04 <- OSPF Router Id

        00 01 <- NLRI type (1 - nodeNLRI)
        00 2d <- NLRI length (45)
        03 <- ProtocolID - OSPF
        00 00 00 00 00 00 00 01 <- identifier
        01 00 <- local node descriptor type (256)
        00 20 <- length (32)
        02 00 <- node descriptor type (member AS - 512)
        00 04 <- length
        00 00 00 64 <- value (100)
        02 01 <- node descriptor type (bgpId - 513)
        00 04 <- length
        19 19 19 01 <- bgpId (25.25.25.1)
        02 02 <- node descriptor type (areaId - 514)
        00 04 <- length
        00 00 00 00 <- value
        02 03 <- node descriptor type (routeId - 515)
        00 04 <- length
        01 01 01 02  <- OSPF Router Id

        40 <- attribute flags
        01 <- attribute type (Origin)
        01 <- attribute length
        00 <- value (IGP)
        40 <- attribute flags
        02 <- attribute type (AS Path)
        00 <- length
        40 <- attribute flags
        05 <- attribute type (local pref)
        04 <- length
        00 00 00 64 <- value
     */
@Test
public void testBGPNode() throws Exception {
    final byte[] body = ByteArray.cutBytes(inputBytes.get(2), MessageUtil.COMMON_HEADER_LENGTH);
    final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(2), MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
    final Update message = ParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength);
    final UpdateBuilder builder = new UpdateBuilder();
    // check fields
    assertNull(message.getWithdrawnRoutes());
    // attributes
    final Ipv4NextHopCase nextHop = new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("25.25.25.1")).build()).build();
    final CLinkstateDestinationBuilder clBuilder = new CLinkstateDestinationBuilder();
    clBuilder.setIdentifier(new Identifier(BigInteger.ONE));
    clBuilder.setProtocolId(ProtocolId.Ospf);
    final NodeDescriptorsBuilder n = new NodeDescriptorsBuilder();
    n.setAsNumber(new AsNumber((long) 100)).setDomainId(new DomainIdentifier(0x19191901L)).setAreaId(new AreaIdentifier(0L));
    final List<CLinkstateDestination> linkstates = Lists.newArrayList();
    final NodeCaseBuilder nCase = new NodeCaseBuilder();
    nCase.setNodeDescriptors(n.setCRouterIdentifier(new OspfPseudonodeCaseBuilder().setOspfPseudonode(new OspfPseudonodeBuilder().setOspfRouterId(0x03030304L).setLanInterface(new OspfInterfaceIdentifier(0x0b0b0b03L)).build()).build()).build());
    linkstates.add(clBuilder.setObjectType(nCase.build()).build());
    nCase.setNodeDescriptors(n.setCRouterIdentifier(new OspfNodeCaseBuilder().setOspfNode(new OspfNodeBuilder().setOspfRouterId(0x03030304L).build()).build()).build());
    linkstates.add(clBuilder.setObjectType(nCase.build()).build());
    nCase.setNodeDescriptors(n.setCRouterIdentifier(new OspfNodeCaseBuilder().setOspfNode(new OspfNodeBuilder().setOspfRouterId(0x01010102L).build()).build()).build());
    linkstates.add(clBuilder.setObjectType(nCase.build()).build());
    final Attributes1Builder lsBuilder = new Attributes1Builder();
    final MpReachNlriBuilder mpBuilder = new MpReachNlriBuilder();
    mpBuilder.setAfi(LinkstateAddressFamily.class);
    mpBuilder.setSafi(LinkstateSubsequentAddressFamily.class);
    mpBuilder.setCNextHop(nextHop);
    final DestinationLinkstateBuilder dBuilder = new DestinationLinkstateBuilder();
    dBuilder.setCLinkstateDestination(linkstates);
    mpBuilder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new DestinationLinkstateCaseBuilder().setDestinationLinkstate(dBuilder.build()).build()).build());
    lsBuilder.setMpReachNlri(mpBuilder.build());
    // check path attributes
    final Attributes attrs = message.getAttributes();
    final AttributesBuilder paBuilder = new AttributesBuilder();
    paBuilder.setOrigin(new OriginBuilder().setValue(BgpOrigin.Igp).build());
    assertEquals(paBuilder.getOrigin(), attrs.getOrigin());
    paBuilder.setAsPath(new AsPathBuilder().setSegments(Collections.emptyList()).build());
    assertEquals(paBuilder.getAsPath(), attrs.getAsPath());
    paBuilder.setLocalPref(new LocalPrefBuilder().setPref(100L).build());
    assertEquals(paBuilder.getLocalPref(), attrs.getLocalPref());
    paBuilder.addAugmentation(Attributes1.class, lsBuilder.build());
    paBuilder.setUnrecognizedAttributes(Collections.emptyList());
    final MpReachNlri mp = attrs.getAugmentation(Attributes1.class).getMpReachNlri();
    assertEquals(mpBuilder.getAfi(), mp.getAfi());
    assertEquals(mpBuilder.getSafi(), mp.getSafi());
    assertEquals(mpBuilder.getCNextHop(), mp.getCNextHop());
    final List<CLinkstateDestination> dests = ((DestinationLinkstateCase) mp.getAdvertizedRoutes().getDestinationType()).getDestinationLinkstate().getCLinkstateDestination();
    assertEquals(linkstates.size(), dests.size());
    assertEquals(linkstates, dests);
    // check API message
    builder.setAttributes(paBuilder.build());
    assertEquals(builder.build(), message);
    final ByteBuf buffer = Unpooled.buffer();
    ParserTest.updateParser.serializeMessage(message, buffer);
    assertArrayEquals(inputBytes.get(2), ByteArray.readAllBytes(buffer));
}
Also used : NodeCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.NodeCaseBuilder) OspfNodeCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.node.identifier.c.router.identifier.OspfNodeCaseBuilder) LocalPrefBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.LocalPrefBuilder) MpReachNlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlriBuilder) OriginBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.OriginBuilder) CLinkstateDestinationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.destination.CLinkstateDestinationBuilder) DestinationLinkstateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.destination.linkstate._case.DestinationLinkstateBuilder) Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes) UpdateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.UpdateBuilder) Update(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update) DestinationLinkstateCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationLinkstateCaseBuilder) ByteBuf(io.netty.buffer.ByteBuf) AsPathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.AsPathBuilder) OspfInterfaceIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.OspfInterfaceIdentifier) AreaIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.AreaIdentifier) Ipv4InterfaceIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Ipv4InterfaceIdentifier) Identifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Identifier) DomainIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.DomainIdentifier) Ipv4NextHopCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv4NextHopCaseBuilder) OspfNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.node.identifier.c.router.identifier.ospf.node._case.OspfNodeBuilder) OspfPseudonodeCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.node.identifier.c.router.identifier.OspfPseudonodeCaseBuilder) OspfNodeCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.node.identifier.c.router.identifier.OspfNodeCaseBuilder) CLinkstateDestination(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.destination.CLinkstateDestination) OspfPseudonodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.node.identifier.c.router.identifier.ospf.pseudonode._case.OspfPseudonodeBuilder) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) DomainIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.DomainIdentifier) Attributes1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1) Ipv4NextHopCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv4NextHopCase) AsNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber) LocalNodeDescriptorsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.link._case.LocalNodeDescriptorsBuilder) NodeDescriptorsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.node._case.NodeDescriptorsBuilder) RemoteNodeDescriptorsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.link._case.RemoteNodeDescriptorsBuilder) Attributes1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1Builder) AdvertizedRoutesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.reach.nlri.AdvertizedRoutesBuilder) Ipv4NextHopBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder) AreaIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.AreaIdentifier) OspfInterfaceIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.OspfInterfaceIdentifier) LinkAttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.path.attribute.link.state.attribute.link.attributes._case.LinkAttributesBuilder) 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) Test(org.junit.Test)

Aggregations

BgpId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpId)12 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)9 BGPSessionPreferences (org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences)7 AsNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)7 InetSocketAddress (java.net.InetSocketAddress)5 Before (org.junit.Before)5 PathSelectionMode (org.opendaylight.protocol.bgp.mode.api.PathSelectionMode)5 RibId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.RibId)5 TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey)5 Test (org.junit.Test)4 UpdateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.UpdateBuilder)4 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)4 AsPathBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.AsPathBuilder)4 LocalPrefBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.LocalPrefBuilder)4 OriginBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.OriginBuilder)4 Ipv4NextHopCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv4NextHopCaseBuilder)4 Ipv4NextHopBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder)4 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)4 ChannelFuture (io.netty.channel.ChannelFuture)3 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)3