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 testTrafficRateSerializer.
@Test
public void testTrafficRateSerializer() 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.TrafficRateExtendedCommunityCase trafficRate = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.bgp.rib.route.attributes.extended.communities.extended.community.TrafficRateExtendedCommunityCaseBuilder().setTrafficRateExtendedCommunity(new TrafficRateExtendedCommunityBuilder().setInformativeAs(new ShortAsNumber(Uint32.valueOf(72))).setLocalAdministrator(new Bandwidth(new byte[] { 0, 1, 2, 3 })).build()).build();
final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(trafficRate).setTransitive(true).build();
final ByteBuf output = Unpooled.buffer(TRAFFIC_RATE.length);
this.registry.serializeExtendedCommunity(expected, output);
Assert.assertArrayEquals(TRAFFIC_RATE, output.array());
}
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 testredirect2bSerializer.
@Test
public void testredirect2bSerializer() 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.RedirectExtendedCommunityCase redirect = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.bgp.rib.route.attributes.extended.communities.extended.community.RedirectExtendedCommunityCaseBuilder().setRedirectExtendedCommunity(new RedirectExtendedCommunityBuilder().setGlobalAdministrator(new ShortAsNumber(Uint32.valueOf(35))).setLocalAdministrator(new byte[] { 4, 2, 8, 7 }).build()).build();
final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(redirect).setTransitive(true).build();
final ByteBuf output = Unpooled.buffer(REDIRECT_AS_2BYTES.length);
this.registry.serializeExtendedCommunity(expected, output);
Assert.assertArrayEquals(REDIRECT_AS_2BYTES, output.array());
}
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 VpnNonMemberHandlerTest method testExtComAny.
@Test
public void testExtComAny() {
Statement statement = this.basicStatements.stream().filter(st -> st.getName().equals("vpn-non-member-test")).findFirst().get();
RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().setExtendedCommunities(Collections.singletonList(new ExtendedCommunitiesBuilder().setExtendedCommunity(new As4RouteTargetExtendedCommunityCaseBuilder().setAs4RouteTargetExtendedCommunity(RT).build()).build())).build());
doReturn(Collections.singletonList(RT)).when(this.exportParameters).getMemberships();
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(this.baseAttributes, IPV4UNICAST.class, this.exportParameters, attributeContainer, statement);
assertNotNull(result.getAttributes());
doReturn(Collections.emptyList()).when(this.exportParameters).getMemberships();
result = this.statementRegistry.applyExportStatement(this.baseAttributes, IPV4UNICAST.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 ExtendedCommunitiesAttributeParserTest method testExtendedCommunityAttributeParser.
@Test
public void testExtendedCommunityAttributeParser() throws BGPDocumentedException, BGPParsingException {
final RouteOriginExtendedCommunityCase routeOrigin = new RouteOriginExtendedCommunityCaseBuilder().setRouteOriginExtendedCommunity(new RouteOriginExtendedCommunityBuilder().setGlobalAdministrator(new ShortAsNumber(Uint32.valueOf(54))).setLocalAdministrator(new byte[] { 0, 0, 1, 76 }).build()).build();
final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setTransitive(false).setExtendedCommunity(routeOrigin).build();
final AttributesBuilder attBuilder = new AttributesBuilder();
this.handler.parseAttribute(Unpooled.copiedBuffer(INPUT), attBuilder, null);
final ExtendedCommunities parsed = attBuilder.getExtendedCommunities().get(0);
assertEquals(expected, parsed);
final ByteBuf output = Unpooled.buffer(INPUT.length);
this.handler.serializeAttribute(attBuilder.build(), output);
assertArrayEquals(Bytes.concat(new byte[] { (byte) 192, 16, 8 }, INPUT), ByteArray.readAllBytes(output));
}
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 CommunitiesBuilder method createExtComm.
static List<ExtendedCommunities> createExtComm(final List<String> extCom) {
final List<ExtendedCommunities> extendedCommunities = new ArrayList<>();
for (String ec : extCom) {
ExtendedCommunity community = null;
switch(ec) {
case "as-4-generic-spec-extended-community":
community = CommunitiesBuilder.as4GenSpecBuild();
break;
case "as-4-route-target-extended-community":
community = CommunitiesBuilder.as4RTBuild();
break;
case "as-4-route-origin-extended-community":
community = CommunitiesBuilder.as4ROBuild();
break;
case "route-origin":
community = CommunitiesBuilder.rOBuild();
break;
case "route-target":
community = CommunitiesBuilder.rTBuild();
break;
case "route-origin-extended-community":
community = CommunitiesBuilder.rOECBuild();
break;
case "route-target-extended-community":
community = CommunitiesBuilder.rTECBuild();
break;
case "link-bandwidth-extended-community":
community = CommunitiesBuilder.linkBandBuild();
break;
case "opaque-extended-community":
community = CommunitiesBuilder.opaqueBuild();
break;
case "inet4-specific-extended-community":
community = CommunitiesBuilder.inet4Build();
break;
case "as-specific-extended-community":
community = CommunitiesBuilder.asSpecBuild();
break;
default:
LOG.debug("Not recognized Extended Community {}", ec);
break;
}
extendedCommunities.add(new ExtendedCommunitiesBuilder().setTransitive(true).setExtendedCommunity(community).build());
}
return extendedCommunities;
}
Aggregations