Search in sources :

Example 1 with TrafficActionExtendedCommunityCase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.bgp.rib.route.attributes.extended.communities.extended.community.TrafficActionExtendedCommunityCase in project bgpcep by opendaylight.

the class FSExtendedCommunitiesTest method testTrafficActionParser.

@Test
public void testTrafficActionParser() throws BGPDocumentedException, BGPParsingException {
    final TrafficActionExtendedCommunityCase trafficAction = new TrafficActionExtendedCommunityCaseBuilder().setTrafficActionExtendedCommunity(new TrafficActionExtendedCommunityBuilder().setSample(true).setTerminalAction(true).build()).build();
    final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(trafficAction).setTransitive(true).build();
    final ExtendedCommunities parsed = this.registry.parseExtendedCommunity(Unpooled.copiedBuffer(TRAFFIC_ACTION));
    Assert.assertEquals(expected, parsed);
}
Also used : TrafficActionExtendedCommunityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.traffic.action.extended.community.TrafficActionExtendedCommunityBuilder) TrafficActionExtendedCommunityCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.update.attributes.extended.communities.extended.community.TrafficActionExtendedCommunityCaseBuilder) TrafficActionExtendedCommunityCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.update.attributes.extended.communities.extended.community.TrafficActionExtendedCommunityCase) ExtendedCommunities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ExtendedCommunities) ExtendedCommunitiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ExtendedCommunitiesBuilder) Test(org.junit.Test)

Example 2 with TrafficActionExtendedCommunityCase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.bgp.rib.route.attributes.extended.communities.extended.community.TrafficActionExtendedCommunityCase in project bgpcep by opendaylight.

the class TrafficActionEcHandler method serializeExtendedCommunity.

@Override
public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) {
    Preconditions.checkArgument(extendedCommunity instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.TrafficActionExtendedCommunity, "The extended community %s is not TrafficActionExtendedCommunityCase type.", extendedCommunity);
    final TrafficActionExtendedCommunity trafficAction = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.TrafficActionExtendedCommunity) extendedCommunity).getTrafficActionExtendedCommunity();
    byteAggregator.writeZero(RESERVED);
    final BitArray flags = new BitArray(FLAGS_SIZE);
    flags.set(SAMPLE_BIT, trafficAction.isSample());
    flags.set(TERMINAL_BIT, trafficAction.isTerminalAction());
    flags.toByteBuf(byteAggregator);
}
Also used : Preconditions(com.google.common.base.Preconditions) TrafficActionExtendedCommunity(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.traffic.action.extended.community.TrafficActionExtendedCommunity) BitArray(org.opendaylight.protocol.util.BitArray)

Aggregations

Preconditions (com.google.common.base.Preconditions)1 Test (org.junit.Test)1 BitArray (org.opendaylight.protocol.util.BitArray)1 TrafficActionExtendedCommunity (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.traffic.action.extended.community.TrafficActionExtendedCommunity)1 TrafficActionExtendedCommunityBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.traffic.action.extended.community.TrafficActionExtendedCommunityBuilder)1 TrafficActionExtendedCommunityCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.update.attributes.extended.communities.extended.community.TrafficActionExtendedCommunityCase)1 TrafficActionExtendedCommunityCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.update.attributes.extended.communities.extended.community.TrafficActionExtendedCommunityCaseBuilder)1 ExtendedCommunities (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ExtendedCommunities)1 ExtendedCommunitiesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ExtendedCommunitiesBuilder)1