use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.update.attributes.extended.communities.extended.community.TrafficRateExtendedCommunityCaseBuilder in project bgpcep by opendaylight.
the class FSExtendedCommunitiesTest method testTrafficRateParser.
@Test
public void testTrafficRateParser() throws BGPDocumentedException, BGPParsingException {
final TrafficRateExtendedCommunityCase trafficRate = new TrafficRateExtendedCommunityCaseBuilder().setTrafficRateExtendedCommunity(new TrafficRateExtendedCommunityBuilder().setInformativeAs(new ShortAsNumber(72L)).setLocalAdministrator(new Bandwidth(new byte[] { 0, 1, 2, 3 })).build()).build();
final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(trafficRate).setTransitive(true).build();
final ExtendedCommunities parsed = this.registry.parseExtendedCommunity(Unpooled.copiedBuffer(TRAFFIC_RATE));
Assert.assertEquals(expected, parsed);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.update.attributes.extended.communities.extended.community.TrafficRateExtendedCommunityCaseBuilder in project bgpcep by opendaylight.
the class TrafficRateEcHandler method parseExtendedCommunity.
@Override
public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException {
final ShortAsNumber as = new ShortAsNumber((long) buffer.readUnsignedShort());
final Bandwidth value = new Bandwidth(ByteArray.readBytes(buffer, TRAFFIC_RATE_SIZE));
return new TrafficRateExtendedCommunityCaseBuilder().setTrafficRateExtendedCommunity(new TrafficRateExtendedCommunityBuilder().setInformativeAs(as).setLocalAdministrator(value).build()).build();
}
Aggregations