use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunities in project bgpcep by opendaylight.
the class SimpleExtendedCommunityRegistryTest method testExtendedCommunityRegistry.
@Test
public void testExtendedCommunityRegistry() throws BGPDocumentedException, BGPParsingException {
final ByteBuf output = Unpooled.buffer();
this.register.serializeExtendedCommunity(new ExtendedCommunitiesBuilder().setTransitive(true).setExtendedCommunity(new RouteTargetIpv4CaseBuilder().setRouteTargetIpv4(new RouteTargetIpv4Builder().build()).build()).build(), output);
verify(this.serializer).serializeExtendedCommunity(any(ExtendedCommunity.class), any(ByteBuf.class));
// no value serialized, just header
Assert.assertEquals(2, output.readableBytes());
final ExtendedCommunities parsedExtendedCommunity = this.register.parseExtendedCommunity(Unpooled.copiedBuffer(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }));
verify(this.parser).parseExtendedCommunity(any(ByteBuf.class));
Assert.assertTrue(parsedExtendedCommunity.getTransitive());
// no value parser
assertNull(parsedExtendedCommunity.getExtendedCommunity());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunities in project bgpcep by opendaylight.
the class NonTransitiveAttributesFilterHandler method filterAttributes.
private static Attributes filterAttributes(final Attributes attributes) {
final AttributesBuilder builder = new AttributesBuilder().setCNextHop(attributes.getCNextHop()).setOrigin(attributes.getOrigin()).setAsPath(attributes.getAsPath()).setCommunities(attributes.getCommunities());
final Map<UnrecognizedAttributesKey, UnrecognizedAttributes> oldAtt = attributes.getUnrecognizedAttributes();
if (oldAtt != null) {
// TODO: consider using Maps.filterValues(attributes.getUnrecognizedAttributes(),
// UnrecognizedAttributes::isTransitive)) ?
builder.setUnrecognizedAttributes(attributes.getUnrecognizedAttributes().values().stream().filter(UnrecognizedAttributes::getTransitive).collect(ImmutableMap.toImmutableMap(UnrecognizedAttributes::key, Function.identity())));
}
final List<ExtendedCommunities> oldExt = attributes.getExtendedCommunities();
if (oldExt != null) {
builder.setExtendedCommunities(oldExt.stream().filter(ExtendedCommunity::getTransitive).collect(Collectors.toList()));
}
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunities in project bgpcep by opendaylight.
the class FSExtendedCommunitiesTest method testRedirectIpv4Parser.
@Test
public void testRedirectIpv4Parser() throws BGPDocumentedException, BGPParsingException {
final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(new RedirectIpv4ExtendedCommunityCaseBuilder().setRedirectIpv4(new RedirectIpv4Builder().setGlobalAdministrator(new Ipv4AddressNoZone("127.0.0.1")).setLocalAdministrator(Uint16.valueOf(126)).build()).build()).setTransitive(true).build();
final ExtendedCommunities parsed = this.registry.parseExtendedCommunity(Unpooled.copiedBuffer(REDIRECT_IPV4));
Assert.assertEquals(expected, parsed);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunities in project bgpcep by opendaylight.
the class FSExtendedCommunitiesTest method testredirectIpv6NhSerializer.
@Test
public void testredirectIpv6NhSerializer() throws BGPDocumentedException, BGPParsingException {
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.bgp.rib.route.attributes.extended.communities.extended.community.RedirectIpNhExtendedCommunityCase redirect = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.bgp.rib.route.attributes.extended.communities.extended.community.RedirectIpNhExtendedCommunityCaseBuilder().setRedirectIpNhExtendedCommunity(new RedirectIpNhExtendedCommunityBuilder().setNextHopAddress(new IpAddressNoZone(new Ipv6AddressNoZone("2001::1"))).build()).build();
final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(redirect).setTransitive(true).build();
final ByteBuf output = Unpooled.buffer(REDIRECT_NH_IPV6.length);
this.registry.serializeExtendedCommunity(expected, output);
Assert.assertArrayEquals(REDIRECT_NH_IPV6, output.array());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunities in project bgpcep by opendaylight.
the class FSExtendedCommunitiesTest method testredirectIpv4Serializer.
@Test
public void testredirectIpv4Serializer() throws BGPDocumentedException, BGPParsingException {
final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.bgp.rib.route.attributes.extended.communities.extended.community.RedirectIpv4ExtendedCommunityCaseBuilder().setRedirectIpv4(new RedirectIpv4Builder().setGlobalAdministrator(new Ipv4AddressNoZone("127.0.0.1")).setLocalAdministrator(Uint16.valueOf(126)).build()).build()).setTransitive(true).build();
final ByteBuf output = Unpooled.buffer(REDIRECT_IPV4.length);
this.registry.serializeExtendedCommunity(expected, output);
Assert.assertArrayEquals(REDIRECT_IPV4, output.array());
}
Aggregations