use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes in project bgpcep by opendaylight.
the class EvpnNlriParser method serializeAttribute.
@Override
public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) {
final AttributesReach pathAttributes1 = pathAttributes.augmentation(AttributesReach.class);
final AttributesUnreach pathAttributes2 = pathAttributes.augmentation(AttributesUnreach.class);
if (pathAttributes1 != null) {
final AdvertizedRoutes routes = pathAttributes1.getMpReachNlri().getAdvertizedRoutes();
if (routes != null && routes.getDestinationType() instanceof DestinationEvpnCase) {
final DestinationEvpnCase evpnCase = (DestinationEvpnCase) routes.getDestinationType();
serializeNlri(evpnCase.getDestinationEvpn().getEvpnDestination(), byteAggregator);
}
} else if (pathAttributes2 != null) {
final MpUnreachNlri mpUnreachNlri = pathAttributes2.getMpUnreachNlri();
final WithdrawnRoutes withdrawnRoutes = mpUnreachNlri.getWithdrawnRoutes();
if (withdrawnRoutes != null && withdrawnRoutes.getDestinationType() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationEvpnCase) {
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationEvpnCase evpnCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationEvpnCase) mpUnreachNlri.getWithdrawnRoutes().getDestinationType();
serializeNlri(evpnCase.getDestinationEvpn().getEvpnDestination(), byteAggregator);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes in project bgpcep by opendaylight.
the class EvpnRibSupportTest method testChangedRoutes.
@Test
public void testChangedRoutes() {
final Routes emptyCase = new EvpnRoutesCaseBuilder().build();
DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(emptyCase)).getRootNode();
Assert.assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
final Routes emptyRoutes = new EvpnRoutesCaseBuilder().setEvpnRoutes(new EvpnRoutesBuilder().build()).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(emptyRoutes)).getRootNode();
Assert.assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
final Routes routes = new EvpnRoutesCaseBuilder().setEvpnRoutes(EVPN_ROUTES).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(routes)).getRootNode();
final Collection<DataTreeCandidateNode> result = this.ribSupport.changedRoutes(tree);
Assert.assertFalse(result.isEmpty());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes in project bgpcep by opendaylight.
the class IPv6RIBSupportTest method testBuildMpUnreachNlriUpdate.
@Test
public void testBuildMpUnreachNlriUpdate() {
final Update update = this.ribSupport.buildUpdate(Collections.emptyList(), createRoutes(ROUTES), ATTRIBUTES);
assertEquals(UNREACH_NLRI, update.getAttributes().augmentation(AttributesUnreach.class).getMpUnreachNlri().getWithdrawnRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesReach.class));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes in project bgpcep by opendaylight.
the class IPv6RIBSupportTest method testChangedRoutes.
@Test
public void testChangedRoutes() {
final Routes emptyCase = new Ipv6RoutesCaseBuilder().build();
DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(emptyCase)).getRootNode();
Assert.assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
final Routes emptyRoutes = new Ipv6RoutesCaseBuilder().setIpv6Routes(new Ipv6RoutesBuilder().build()).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(emptyRoutes)).getRootNode();
Assert.assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
final Routes routes = new Ipv6RoutesCaseBuilder().setIpv6Routes(ROUTES).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(routes)).getRootNode();
final Collection<DataTreeCandidateNode> result = this.ribSupport.changedRoutes(tree);
Assert.assertFalse(result.isEmpty());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes 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);
}
Aggregations