Search in sources :

Example 26 with BGP

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.BGP in project bgpcep by opendaylight.

the class AddPathNPathsTest method testUseCase1.

/*
     * N-Paths
     *                                            ___________________
     *                                           | ODL BGP 127.0.0.1 |
     * [peer://127.0.0.2; p1, lp100] --(iBGP)--> |                   | --(RR-client, non add-path) --> [Peer://127.0.0.5; (p1, lp100), (p1, lp1200)]
     * [peer://127.0.0.3; p1, lp200] --(iBGP)--> |                   |
     * [peer://127.0.0.4; p1, lp50] --(iBGP)-->  |                   | --(RR-client, add-path) --> [Peer://127.0.0.6; (p1, path-id1, lp100), (p1, path-id2, pl50), (p1, path-id3, pl200)]
     * [peer://127.0.0.2; p1, lp20] --(iBGP)-->  |___________________|
     * p1 = 1.1.1.1/32
     */
@Test
public void testUseCase1() throws Exception {
    final BgpParameters nonAddPathParams = createParameter(false);
    final BgpParameters addPathParams = createParameter(true);
    configurePeer(PEER1, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
    final BGPSessionImpl session1 = createPeerSession(PEER1, nonAddPathParams, new SimpleSessionListener());
    configurePeer(PEER2, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
    final BGPSessionImpl session2 = createPeerSession(PEER2, nonAddPathParams, new SimpleSessionListener());
    configurePeer(PEER3, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
    final BGPSessionImpl session3 = createPeerSession(PEER3, nonAddPathParams, new SimpleSessionListener());
    final SimpleSessionListener listener4 = new SimpleSessionListener();
    configurePeer(PEER4, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
    final BGPSessionImpl session4 = createPeerSession(PEER4, nonAddPathParams, listener4);
    final SimpleSessionListener listener5 = new SimpleSessionListener();
    configurePeer(PEER5, this.ribImpl, addPathParams, PeerRole.RrClient, this.serverRegistry);
    final BGPSessionImpl session5 = createPeerSession(PEER5, addPathParams, listener5);
    checkPeersPresentOnDataStore(5);
    // new best route so far
    sendRouteAndCheckIsOnLocRib(session1, PREFIX1, 100, 1);
    checkReceivedMessages(listener4, 1);
    checkReceivedMessages(listener5, 1);
    assertEquals(UPD_100, listener5.getListMsg().get(0));
    final SimpleSessionListener listener6 = new SimpleSessionListener();
    configurePeer(PEER6, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
    final BGPSessionImpl session6 = createPeerSession(PEER6, nonAddPathParams, listener6);
    checkPeersPresentOnDataStore(6);
    checkReceivedMessages(listener6, 1);
    assertEquals(UPD_NA_100, listener6.getListMsg().get(0));
    session6.close();
    checkPeersPresentOnDataStore(5);
    // the second best route
    sendRouteAndCheckIsOnLocRib(session2, PREFIX1, 50, 2);
    checkReceivedMessages(listener4, 1);
    checkReceivedMessages(listener5, 2);
    assertEquals(UPD_50, listener5.getListMsg().get(1));
    // new best route
    sendRouteAndCheckIsOnLocRib(session3, PREFIX1, 200, 2);
    checkReceivedMessages(listener4, 2);
    checkReceivedMessages(listener5, 3);
    assertEquals(UPD_200, listener5.getListMsg().get(2));
    // the worst prefix, no changes
    sendRouteAndCheckIsOnLocRib(session2, PREFIX1, 20, 2);
    checkReceivedMessages(listener4, 2);
    checkReceivedMessages(listener5, 3);
    // withdraw second best route, 2 advertisement (1 withdrawal) for add-path supported, none for non add path
    sendWithdrawalRouteAndCheckIsOnLocRib(session1, PREFIX1, 100, 2);
    checkReceivedMessages(listener4, 2);
    checkReceivedMessages(listener5, 5);
    // we advertise again to try new test
    sendRouteAndCheckIsOnLocRib(session1, PREFIX1, 100, 2);
    checkReceivedMessages(listener4, 2);
    checkReceivedMessages(listener5, 6);
    // withdraw second best route, 2 advertisement (1 withdrawal) for add-path supported, 1 withdrawal for non add path
    sendWithdrawalRouteAndCheckIsOnLocRib(session3, PREFIX1, 200, 2);
    checkReceivedMessages(listener4, 3);
    checkReceivedMessages(listener5, 8);
    session1.close();
    session2.close();
    session3.close();
    session4.close();
    session5.close();
}
Also used : BgpParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters) Test(org.junit.Test)

Example 27 with BGP

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.BGP 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 28 with BGP

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.BGP in project bgpcep by opendaylight.

the class StrictBGPPeerRegistry method getPeer.

@Override
public synchronized BGPSessionListener getPeer(final IpAddress ip, final Ipv4Address sourceId, final Ipv4Address remoteId, final Open openObj) throws BGPDocumentedException {
    requireNonNull(ip);
    requireNonNull(sourceId);
    requireNonNull(remoteId);
    final AsNumber remoteAsNumber = AsNumberUtil.advertizedAsNumber(openObj);
    requireNonNull(remoteAsNumber);
    final BGPSessionPreferences prefs = getPeerPreferences(ip);
    checkPeerConfigured(ip);
    final BGPSessionId currentConnection = new BGPSessionId(sourceId, remoteId, remoteAsNumber);
    final BGPSessionListener p = this.peers.get(ip);
    final BGPSessionId previousConnection = this.sessionIds.get(ip);
    if (previousConnection != null) {
        LOG.warn("Duplicate BGP session established with {}", ip);
        // Session reestablished with different ids
        if (!previousConnection.equals(currentConnection)) {
            LOG.warn("BGP session with {} {} has to be dropped. Same session already present {}", ip, currentConnection, previousConnection);
            throw new BGPDocumentedException(String.format("BGP session with %s %s has to be dropped. Same session already present %s", ip, currentConnection, previousConnection), BGPError.CEASE);
        // Session reestablished with lower source bgp id, dropping current
        } else if (previousConnection.isHigherDirection(currentConnection) || previousConnection.hasHigherAsNumber(currentConnection)) {
            LOG.warn("BGP session with {} {} has to be dropped. Opposite session already present", ip, currentConnection);
            throw new BGPDocumentedException(String.format("BGP session with %s initiated %s has to be dropped. " + "Opposite session already present", ip, currentConnection), BGPError.CEASE);
        // Session reestablished with higher source bgp id, dropping previous
        } else if (currentConnection.isHigherDirection(previousConnection) || currentConnection.hasHigherAsNumber(previousConnection)) {
            LOG.warn("BGP session with {} {} released. Replaced by opposite session", ip, previousConnection);
            this.peers.get(ip).releaseConnection();
            return this.peers.get(ip);
        // Session reestablished with same source bgp id, dropping current as duplicate
        } else {
            LOG.warn("BGP session with %s initiated from %s to %s has to be dropped. Same session already present", ip, sourceId, remoteId);
            throw new BGPDocumentedException(String.format("BGP session with %s initiated %s has to be dropped. " + "Same session already present", ip, currentConnection), BGPError.CEASE);
        }
    }
    validateAs(remoteAsNumber, openObj, prefs);
    // Map session id to peer IP address
    this.sessionIds.put(ip, currentConnection);
    for (final PeerRegistrySessionListener peerRegistrySessionListener : this.sessionListeners) {
        peerRegistrySessionListener.onSessionCreated(ip);
    }
    return p;
}
Also used : BGPSessionListener(org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener) BGPSessionPreferences(org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences) BGPDocumentedException(org.opendaylight.protocol.bgp.parser.BGPDocumentedException) PeerRegistrySessionListener(org.opendaylight.protocol.bgp.rib.impl.spi.PeerRegistrySessionListener) AsNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)

Example 29 with BGP

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.BGP 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)

Example 30 with BGP

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.BGP in project bgpcep by opendaylight.

the class SrAttributeParserTest method testSrAdjId.

// tools.ietf.org/html/draft-gredler-idr-bgp-ls-segment-routing-ext-00#section-2.2.1
@Test
public void testSrAdjId() {
    final byte[] tested = { (byte) 0x60, 10, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
    final byte[] testedOspf = { (byte) 0xc0, 10, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
    final byte[] sidLabel = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
    final SrAdjIds srAdjId = new SrAdjIdsBuilder().setFlags(ISIS_ADJ_FLAGS).setWeight(new Weight((short) 10)).setSidLabelIndex(new Ipv6AddressCaseBuilder().setIpv6Address(Ipv6Util.addressForByteBuf(Unpooled.copiedBuffer(sidLabel))).build()).build();
    final SrAdjIds ospfAdj = new SrAdjIdsBuilder().setFlags(OSPF_ADJ_FLAGS).setWeight(new Weight((short) 10)).setSidLabelIndex(new Ipv6AddressCaseBuilder().setIpv6Address(Ipv6Util.addressForByteBuf(Unpooled.copiedBuffer(sidLabel))).build()).build();
    assertEquals(srAdjId, new SrAdjIdsBuilder(SrLinkAttributesParser.parseAdjacencySegmentIdentifier(Unpooled.wrappedBuffer(tested), ProtocolId.IsisLevel1)).build());
    assertEquals(ospfAdj, new SrAdjIdsBuilder(SrLinkAttributesParser.parseAdjacencySegmentIdentifier(Unpooled.wrappedBuffer(testedOspf), ProtocolId.Ospf)).build());
    final ByteBuf serializedData = SrLinkAttributesParser.serializeAdjacencySegmentIdentifier(srAdjId);
    final ByteBuf serializedOspf = SrLinkAttributesParser.serializeAdjacencySegmentIdentifier(ospfAdj);
    assertArrayEquals(tested, ByteArray.readAllBytes(serializedData));
    assertArrayEquals(testedOspf, ByteArray.readAllBytes(serializedOspf));
}
Also used : SrAdjIds(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.attribute.SrAdjIds) SrAdjIdsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.attribute.SrAdjIdsBuilder) Ipv6AddressCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.sid.label.index.sid.label.index.Ipv6AddressCaseBuilder) ByteBuf(io.netty.buffer.ByteBuf) Weight(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.Weight) Test(org.junit.Test)

Aggregations

BigInteger (java.math.BigInteger)18 Test (org.junit.Test)17 ByteBuf (io.netty.buffer.ByteBuf)16 ArrayList (java.util.ArrayList)16 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)16 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)11 VrfEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry)10 ExecutionException (java.util.concurrent.ExecutionException)9 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)9 BGPDocumentedException (org.opendaylight.protocol.bgp.parser.BGPDocumentedException)9 Bgp (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.Bgp)7 BgpParameters (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters)7 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)7 List (java.util.List)6 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)6 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)6 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)5 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)5 Neighbors (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.Neighbors)5 Collections (java.util.Collections)4