Search in sources :

Example 16 with Community

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Community in project bgpcep by opendaylight.

the class Ipv4SpecificEcHandler method serializeExtendedCommunity.

@Override
public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) {
    checkArgument(extendedCommunity instanceof Inet4SpecificExtendedCommunityCase, "The extended community %s is not Inet4SpecificExtendedCommunityCase type.", extendedCommunity);
    final Inet4SpecificExtendedCommunity inet4SpecificExtendedCommunity = ((Inet4SpecificExtendedCommunityCase) extendedCommunity).getInet4SpecificExtendedCommunity();
    final Inet4SpecificExtendedCommunityCommon common = inet4SpecificExtendedCommunity.getInet4SpecificExtendedCommunityCommon();
    if (common != null) {
        serializeCommon(inet4SpecificExtendedCommunity.getInet4SpecificExtendedCommunityCommon(), byteAggregator);
    } else {
        Ipv4Util.writeIpv4Address(inet4SpecificExtendedCommunity.getGlobalAdministrator(), byteAggregator);
        byteAggregator.writeBytes(inet4SpecificExtendedCommunity.getLocalAdministrator());
    }
}
Also used : Inet4SpecificExtendedCommunity(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.extended.community.inet4.specific.extended.community._case.Inet4SpecificExtendedCommunity) Inet4SpecificExtendedCommunityCommon(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.inet4.specific.extended.community.common.Inet4SpecificExtendedCommunityCommon) Inet4SpecificExtendedCommunityCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.extended.community.Inet4SpecificExtendedCommunityCase)

Example 17 with Community

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Community in project bgpcep by opendaylight.

the class RouteOriginIpv4EcHandler method serializeExtendedCommunity.

@Override
public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) {
    checkArgument(extendedCommunity instanceof RouteOriginIpv4Case, "The extended community %s is not RouteOriginIpv4Case type.", extendedCommunity);
    final RouteOriginIpv4 routeTarget = ((RouteOriginIpv4Case) extendedCommunity).getRouteOriginIpv4();
    Ipv4Util.writeIpv4Address(routeTarget.getGlobalAdministrator(), byteAggregator);
    ByteBufUtils.writeOrZero(byteAggregator, routeTarget.getLocalAdministrator());
}
Also used : RouteOriginIpv4(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.extended.community.route.origin.ipv4._case.RouteOriginIpv4) RouteOriginIpv4Case(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.extended.community.RouteOriginIpv4Case)

Example 18 with Community

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Community in project bgpcep by opendaylight.

the class VrfRouteImportHandler method serializeExtendedCommunity.

@Override
public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) {
    Preconditions.checkArgument(extendedCommunity instanceof VrfRouteImportExtendedCommunityCase, "The extended community %s is not VrfRouteImportExtendedCommunityCase type.", extendedCommunity);
    final VrfRouteImportExtendedCommunity inet4SpecificExtendedCommunity = ((VrfRouteImportExtendedCommunityCase) extendedCommunity).getVrfRouteImportExtendedCommunity();
    serializeCommon(inet4SpecificExtendedCommunity.getInet4SpecificExtendedCommunityCommon(), byteAggregator);
}
Also used : VrfRouteImportExtendedCommunity(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.extended.community.vrf.route._import.extended.community._case.VrfRouteImportExtendedCommunity) VrfRouteImportExtendedCommunityCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.extended.community.VrfRouteImportExtendedCommunityCase)

Example 19 with Community

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Community in project bgpcep by opendaylight.

the class MatchCommunityTest method testComAll.

@Test
public void testComAll() {
    Statement statement = this.basicStatements.stream().filter(st -> st.getName().equals("community-all-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().setCommunities(Arrays.asList(new CommunitiesBuilder().setAsNumber(AsNumber.getDefaultInstance("65")).setSemantics(Uint16.TEN).build(), new CommunitiesBuilder().setAsNumber(AsNumber.getDefaultInstance("66")).setSemantics(Uint16.valueOf(11)).build())).build());
    result = this.statementRegistry.applyExportStatement(this.baseAttributes, IPV4UNICAST.class, this.exportParameters, attributeContainer, statement);
    assertNull(result.getAttributes());
}
Also used : CommunitiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.CommunitiesBuilder) Statement(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement) RouteAttributeContainer(org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder) IPV4UNICAST(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST) Test(org.junit.Test)

Example 20 with Community

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Community in project bgpcep by opendaylight.

the class SetCommunityTest method testInlineReplace.

@Test
public void testInlineReplace() {
    Statement statement = this.basicStatements.stream().filter(st -> st.getName().equals("set-community-inline-replace-test")).findFirst().get();
    RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().build());
    RouteAttributeContainer result = this.statementRegistry.applyExportStatement(this.baseAttributes, IPV4UNICAST.class, this.exportParameters, attributeContainer, statement);
    assertEquals(this.multipleCom, result.getAttributes());
}
Also used : Statement(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement) RouteAttributeContainer(org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)25 RouteAttributeContainer (org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer)18 Statement (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement)18 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder)17 ArrayList (java.util.ArrayList)7 ByteBuf (io.netty.buffer.ByteBuf)6 IPV4UNICAST (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST)6 ExtendedCommunities (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunities)6 ExtendedCommunitiesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunitiesBuilder)6 PeerSpecificParserConstraint (org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint)5 AsNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)5 Communities (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.Communities)5 CommunitiesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.CommunitiesBuilder)5 Ipv4AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone)3 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)3 Community (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Community)3 As4SpecificCommonBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.as._4.spec.common.As4SpecificCommonBuilder)3 As4RouteOriginExtendedCommunityCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.extended.community.As4RouteOriginExtendedCommunityCaseBuilder)3 As4RouteOriginExtendedCommunityBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.extended.community.as._4.route.origin.extended.community._case.As4RouteOriginExtendedCommunityBuilder)3 BGPTreatAsWithdrawException (org.opendaylight.protocol.bgp.parser.BGPTreatAsWithdrawException)2