use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunitiesBuilder in project bgpcep by opendaylight.
the class SimpleExtendedCommunityRegistryTest method testExtendedCommunityRegistryUnknown.
@Test
public void testExtendedCommunityRegistryUnknown() throws BGPDocumentedException, BGPParsingException {
final ByteBuf output = Unpooled.buffer();
this.register.serializeExtendedCommunity(new ExtendedCommunitiesBuilder().setTransitive(false).setExtendedCommunity(new RouteOriginIpv4CaseBuilder().build()).build(), output);
// no ex. community was serialized
Assert.assertEquals(0, output.readableBytes());
verify(this.serializer, never()).serializeExtendedCommunity(any(ExtendedCommunity.class), any(ByteBuf.class));
final ExtendedCommunities noExtCommunity = this.register.parseExtendedCommunity(Unpooled.copiedBuffer(new byte[] { 0, 1, 0, 0, 0, 0, 0, 0 }));
// no ext. community was parsed
assertNull(noExtCommunity);
verify(this.parser, never()).parseExtendedCommunity(any(ByteBuf.class));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunitiesBuilder in project bgpcep by opendaylight.
the class SimpleExtendedCommunityRegistry method parseExtendedCommunity.
@Override
public ExtendedCommunities parseExtendedCommunity(final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException {
final short type = buffer.readUnsignedByte();
final short subtype = buffer.readUnsignedByte();
final ExtendedCommunityParser parser = this.handlers.getParser(createKey(type, subtype));
if (parser == null) {
buffer.skipBytes(EXTENDED_COMMUNITY_LENGTH);
LOG.info("Skipping unknown extended-community type/sub-type {}/{}.", type, subtype);
return null;
}
return new ExtendedCommunitiesBuilder().setTransitive(isTransitive(type)).setExtendedCommunity(parser.parseExtendedCommunity(buffer)).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunitiesBuilder 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.ExtendedCommunitiesBuilder in project bgpcep by opendaylight.
the class MatchAfiSafiNotInTest method testExtComAny.
@Test
public void testExtComAny() {
Statement statement = this.basicStatements.stream().filter(st -> st.getName().equals("match-afi-safi-not-in-test")).findFirst().get();
RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().build());
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(this.baseAttributes, IPV4UNICAST.class, this.exportParameters, attributeContainer, statement);
assertNotNull(result.getAttributes());
attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().setExtendedCommunities(Collections.singletonList(new ExtendedCommunitiesBuilder().setExtendedCommunity(new As4RouteOriginExtendedCommunityCaseBuilder().setAs4RouteOriginExtendedCommunity(new As4RouteOriginExtendedCommunityBuilder().setAs4SpecificCommon(new As4SpecificCommonBuilder().setAsNumber(AsNumber.getDefaultInstance("65000")).setLocalAdministrator(Uint16.valueOf(123)).build()).build()).build()).build())).build());
result = this.statementRegistry.applyExportStatement(this.baseAttributes, IPV6UNICAST.class, this.exportParameters, attributeContainer, statement);
assertNull(result.getAttributes());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunitiesBuilder 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);
}
Aggregations