Search in sources :

Example 11 with Nlri

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.update.message.Nlri in project bgpcep by opendaylight.

the class BGPParserTest method testParseUpdateMessageWithMalformedAttributes.

/*
     * Tests withdrawn routes with malformed attribute.
     *
     * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
     * 00 36 <- length (54) - including header
     * 02 <- message type
     * 00 00 <- withdrawn routes length
     * 00 1b <- total path attribute length (27)
     * 40 <- attribute flags
     * 01 <- attribute type code (origin)
     * 01 <- WRONG attribute length
     * 00 <- Origin value (IGP)
     * 40 <- attribute flags
     * 03 <- attribute type code (Next Hop)
     * 04 <- attribute length
     * 0a 00 00 02 <- value (10.0.0.2)
     * 40 <- attribute flags
     * 0e <- attribute type code (MP_REACH)
     * 0d <- attribute length
     * 00 01 <- AFI (Ipv4)
     * 01 <- SAFI (Unicast)
     * 04 <- next hop length
     * ff ff ff ff <- next hop
     * 00 <- reserved
     * 18 <- length
     * 0a 00 01 <- prefix (10.0.1.0)
     * //NLRI
     * 18 <- length
     * 0a 00 02 <- prefix (10.0.2.0)
     */
@Test
public void testParseUpdateMessageWithMalformedAttributes() throws Exception {
    final PeerSpecificParserConstraintImpl constraint = new PeerSpecificParserConstraintImpl();
    constraint.addPeerConstraint(RevisedErrorHandlingSupport.class, RevisedErrorHandlingSupportImpl.forExternalPeer());
    final Update message = (Update) messageRegistry.parseMessage(Unpooled.wrappedBuffer(input.get(0)), constraint);
    assertNotNull(message);
    assertNull(message.getNlri());
    final List<WithdrawnRoutes> withdrawnRoutes = message.getWithdrawnRoutes();
    assertNotNull(withdrawnRoutes);
    assertEquals(1, withdrawnRoutes.size());
    final Attributes attributes = message.getAttributes();
    assertNotNull(attributes);
    assertNull(attributes.augmentation(AttributesReach.class));
    final AttributesUnreach AttributesUnreach = attributes.augmentation(AttributesUnreach.class);
    assertNotNull(AttributesUnreach);
    final MpUnreachNlri mpUnreachNlri = AttributesUnreach.getMpUnreachNlri();
    assertNotNull(mpUnreachNlri);
}
Also used : AttributesReach(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesReach) MpUnreachNlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.MpUnreachNlri) Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes) AttributesUnreach(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesUnreach) WithdrawnRoutes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.update.message.WithdrawnRoutes) Update(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update) PeerSpecificParserConstraintImpl(org.opendaylight.protocol.bgp.parser.spi.pojo.PeerSpecificParserConstraintImpl) Test(org.junit.Test)

Example 12 with Nlri

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.update.message.Nlri in project bgpcep by opendaylight.

the class L3vpnMcastIpv6NlriHandler method parseNlri.

@Override
public void parseNlri(final ByteBuf nlri, final MpUnreachNlriBuilder builder, final PeerSpecificParserConstraint constraint) throws BGPParsingException {
    if (!nlri.isReadable()) {
        return;
    }
    final boolean mPathSupported = MultiPathSupportUtil.isTableTypeSupported(constraint, new BgpTableTypeImpl(builder.getAfi(), builder.getSafi()));
    builder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(new DestinationL3vpnMcastIpv6WithdrawnCaseBuilder().setDestinationIpv6L3vpnMcast(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.l3vpn.mcast.rev180417.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.l3vpn.mcast.ipv6.withdrawn._case.DestinationIpv6L3vpnMcastBuilder().setL3vpnMcastDestination(L3vpnMcastNlriSerializer.extractDest(nlri, mPathSupported)).build()).build()).build());
}
Also used : WithdrawnRoutesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.mp.unreach.nlri.WithdrawnRoutesBuilder) BgpTableTypeImpl(org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl) DestinationL3vpnMcastIpv6WithdrawnCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.l3vpn.mcast.rev180417.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationL3vpnMcastIpv6WithdrawnCaseBuilder)

Example 13 with Nlri

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.update.message.Nlri in project bgpcep by opendaylight.

the class L3vpnMcastIpv6NlriHandler method parseNlri.

@Override
public void parseNlri(final ByteBuf nlri, final MpReachNlriBuilder builder, final PeerSpecificParserConstraint constraint) throws BGPParsingException {
    if (!nlri.isReadable()) {
        return;
    }
    final boolean mPathSupported = MultiPathSupportUtil.isTableTypeSupported(constraint, new BgpTableTypeImpl(builder.getAfi(), builder.getSafi()));
    builder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new DestinationL3vpnMcastIpv6AdvertizedCaseBuilder().setDestinationIpv6L3vpnMcast(new DestinationIpv6L3vpnMcastBuilder().setL3vpnMcastDestination(L3vpnMcastNlriSerializer.extractDest(nlri, mPathSupported)).build()).build()).build());
}
Also used : DestinationL3vpnMcastIpv6AdvertizedCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.l3vpn.mcast.rev180417.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationL3vpnMcastIpv6AdvertizedCaseBuilder) AdvertizedRoutesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.mp.reach.nlri.AdvertizedRoutesBuilder) BgpTableTypeImpl(org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl) DestinationIpv6L3vpnMcastBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.l3vpn.mcast.rev180417.update.attributes.mp.reach.nlri.advertized.routes.destination.type.destination.l3vpn.mcast.ipv6.advertized._case.DestinationIpv6L3vpnMcastBuilder)

Example 14 with Nlri

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.update.message.Nlri in project bgpcep by opendaylight.

the class BGPParserTest method testIPv6Nlri.

/*
     * Tests IPv6 NEXT_HOP, NLRI, ORIGIN.IGP, MULTI_EXIT_DISC, ORIGINATOR-ID, CLUSTER_LIST.
     *
     * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
     * 00 80 <- length (128) - including header
     * 02 <- message type
     * 00 00 <- withdrawn routes length
     * 00 69 <- total path attribute length (105)
     * 40 <- attribute flags
     * 01 <- attribute type code (origin)
     * 01 <- attribute length
     * 00 <- Origin value (IGP)
     * 40 <- attribute flags
     * 02 <- attribute type code (as path)
     * 06 <- attribute length
     * 02 <- AS_SEQUENCE
     * 01 <- path segment count
     * 00 00 fd e9 <- path segment value (65001)
     * 40 <- attribute flags
     * 03 <- attribute type code (next hop)
     * 04 <- attribute length
     * 0a 00 00 00 <- next hop value (10.0.0.0)
     * 80 <- attribute flags
     * 04 <- attribute type code (multi exit disc)
     * 04 <- attribute length
     * 00 00 00 00 <- value
     * 80 <- attribute flags
     * 09 <- attribute type code (originator id)
     * 04 <- attribute length
     * 7f 00 00 01 <- value (localhost ip)
     * 80 <- attribute flags
     * 0a <- attribute type code (cluster list)
     * 08 <- attribute length
     * 01 02 03 04 <- value
     * 05 06 07 08 <- value
     * 80 <- attribute flags
     * 0e <- attribute type code (mp reach nlri)
     * 40 <- attribute length
     * 00 02 <- AFI (Ipv6)
     * 01 <- SAFI (Unicast)
     * 20 <- length of next hop
     * 20 01 0d b8 00 00 00 00 00 00 00 00 00 00 00 01 <- global
     * fe 80 00 00 00 00 00 00 c0 01 0b ff fe 7e 00 <- link local
     * 00 <- reserved
     *
     * //NLRI
     * 40 20 01 0d b8 00 01 00 02 <- IPv6 Prefix (2001:db8:1:2:: / 64)
     * 40 20 01 0d b8 00 01 00 01 <- IPv6 Prefix (2001:db8:1:1:: / 64)
     * 40 20 01 0d b8 00 01 00 00 <- IPv6 Prefix (2001:db8:1:: / 64)
     *
     */
@Test
public void testIPv6Nlri() throws Exception {
    final Update message = (Update) messageRegistry.parseMessage(Unpooled.wrappedBuffer(input.get(1)), null);
    // check fields
    assertNull(message.getWithdrawnRoutes());
    final UpdateBuilder builder = new UpdateBuilder();
    // check NLRI
    final List<Ipv6Prefixes> prefs = new ArrayList<>();
    prefs.add(new Ipv6PrefixesBuilder().setPrefix(new Ipv6Prefix("2001:db8:1:2::/64")).build());
    prefs.add(new Ipv6PrefixesBuilder().setPrefix(new Ipv6Prefix("2001:db8:1:1::/64")).build());
    prefs.add(new Ipv6PrefixesBuilder().setPrefix(new Ipv6Prefix("2001:db8:1::/64")).build());
    assertNull(message.getNlri());
    // attributes
    final List<AsNumber> asNumbers = new ArrayList<>();
    asNumbers.add(new AsNumber(Uint32.valueOf(65001)));
    final List<Segments> asPath = new ArrayList<>();
    asPath.add(new SegmentsBuilder().setAsSequence(asNumbers).build());
    final Ipv6NextHopCase nextHop = new Ipv6NextHopCaseBuilder().setIpv6NextHop(new Ipv6NextHopBuilder().setGlobal(new Ipv6AddressNoZone("2001:db8::1")).setLinkLocal(new Ipv6AddressNoZone("fe80::c001:bff:fe7e:0")).build()).build();
    final List<ClusterIdentifier> clusters = Lists.newArrayList(new ClusterIdentifier(new Ipv4AddressNoZone("1.2.3.4")), new ClusterIdentifier(new Ipv4AddressNoZone("5.6.7.8")));
    // 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(asPath).build());
    assertEquals(paBuilder.getAsPath(), attrs.getAsPath());
    paBuilder.setMultiExitDisc(new MultiExitDiscBuilder().setMed(Uint32.ZERO).build());
    assertEquals(paBuilder.getMultiExitDisc(), attrs.getMultiExitDisc());
    paBuilder.setOriginatorId(new OriginatorIdBuilder().setOriginator(new Ipv4AddressNoZone("127.0.0.1")).build());
    assertEquals(paBuilder.getOriginatorId(), attrs.getOriginatorId());
    paBuilder.setClusterId(new ClusterIdBuilder().setCluster(clusters).build());
    assertEquals(paBuilder.getClusterId(), attrs.getClusterId());
    final MpReachNlriBuilder mpBuilder = new MpReachNlriBuilder().setAfi(Ipv6AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).setCNextHop(nextHop).setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new DestinationIpv6CaseBuilder().setDestinationIpv6(new DestinationIpv6Builder().setIpv6Prefixes(prefs).build()).build()).build());
    paBuilder.addAugmentation(new AttributesReachBuilder().setMpReachNlri(mpBuilder.build()).build());
    assertEquals(paBuilder.augmentation(AttributesReach.class).getMpReachNlri(), attrs.augmentation(AttributesReach.class).getMpReachNlri());
    paBuilder.setUnrecognizedAttributes(Collections.emptyMap());
    // check API message
    builder.setAttributes(paBuilder.build());
    assertEquals(builder.build(), message);
    final ByteBuf buffer = Unpooled.buffer();
    messageRegistry.serializeMessage(message, buffer);
    assertArrayEquals(input.get(1), ByteArray.readAllBytes(buffer));
}
Also used : Ipv6AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv6AddressFamily) MpReachNlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.MpReachNlriBuilder) Ipv4AddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone) OriginBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.OriginBuilder) MultiExitDiscBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.MultiExitDiscBuilder) ArrayList(java.util.ArrayList) Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes) Segments(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.as.path.Segments) UpdateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.UpdateBuilder) Update(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update) ByteBuf(io.netty.buffer.ByteBuf) Ipv6AddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressNoZone) Ipv6Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix) Ipv6PrefixesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv6.prefixes.destination.ipv6.Ipv6PrefixesBuilder) AsPathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.AsPathBuilder) AttributesReachBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesReachBuilder) SegmentsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.as.path.SegmentsBuilder) ClusterIdBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ClusterIdBuilder) DestinationIpv6Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv6.prefixes.DestinationIpv6Builder) Ipv6NextHopBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.ipv6.next.hop._case.Ipv6NextHopBuilder) DestinationIpv6CaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv6CaseBuilder) Ipv6Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv6.prefixes.destination.ipv6.Ipv6Prefixes) ClusterIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.ClusterIdentifier) AsNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber) OriginatorIdBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.OriginatorIdBuilder) Ipv6NextHopCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.Ipv6NextHopCase) AdvertizedRoutesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.mp.reach.nlri.AdvertizedRoutesBuilder) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder) Ipv6NextHopCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.Ipv6NextHopCaseBuilder) Test(org.junit.Test)

Example 15 with Nlri

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.update.message.Nlri in project bgpcep by opendaylight.

the class Ipv4NlriParser method prefixes.

private static DestinationIpv4 prefixes(final ByteBuf nlri, final PeerSpecificParserConstraint constraints, final Class<? extends AddressFamily> afi, final Class<? extends SubsequentAddressFamily> safi) {
    final List<Ipv4Prefixes> prefixes = new ArrayList<>();
    while (nlri.isReadable()) {
        final Ipv4PrefixesBuilder prefixesBuilder = new Ipv4PrefixesBuilder();
        if (MultiPathSupportUtil.isTableTypeSupported(constraints, new BgpTableTypeImpl(afi, safi))) {
            prefixesBuilder.setPathId(PathIdUtil.readPathId(nlri));
        }
        prefixesBuilder.setPrefix(Ipv4Util.prefixForByteBuf(nlri));
        prefixes.add(prefixesBuilder.build());
    }
    return new DestinationIpv4Builder().setIpv4Prefixes(prefixes).build();
}
Also used : Ipv4PrefixesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.prefixes.destination.ipv4.Ipv4PrefixesBuilder) Ipv4Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.prefixes.destination.ipv4.Ipv4Prefixes) ArrayList(java.util.ArrayList) BgpTableTypeImpl(org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl) DestinationIpv4Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.prefixes.DestinationIpv4Builder)

Aggregations

ArrayList (java.util.ArrayList)40 ByteBuf (io.netty.buffer.ByteBuf)26 BgpTableTypeImpl (org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl)18 AdvertizedRoutesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.mp.reach.nlri.AdvertizedRoutesBuilder)14 Test (org.junit.Test)13 PeerSpecificParserConstraint (org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint)13 Update (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update)13 Nlri (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.update.message.Nlri)13 UpdateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.UpdateBuilder)12 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder)12 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes)11 NlriBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.update.message.NlriBuilder)11 WithdrawnRoutesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.mp.unreach.nlri.WithdrawnRoutesBuilder)11 Ipv4AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone)10 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)10 NumericOperand (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.NumericOperand)10 AsPathBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.AsPathBuilder)10 OriginBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.OriginBuilder)10 TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey)10 AsNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)9