Search in sources :

Example 1 with RedirectExtendedCommunityBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.redirect.extended.community.RedirectExtendedCommunityBuilder in project bgpcep by opendaylight.

the class RedirectAsTwoOctetEcHandler method parseExtendedCommunity.

@Override
public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer) {
    final ShortAsNumber as1 = new ShortAsNumber(Uint32.valueOf(ByteBufUtils.readUint16(buffer)));
    final byte[] byteValue = ByteArray.readBytes(buffer, TRAFFIC_RATE_SIZE);
    return new RedirectExtendedCommunityCaseBuilder().setRedirectExtendedCommunity(new RedirectExtendedCommunityBuilder().setGlobalAdministrator(as1).setLocalAdministrator(byteValue).build()).build();
}
Also used : RedirectExtendedCommunityCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update.attributes.extended.communities.extended.community.RedirectExtendedCommunityCaseBuilder) ShortAsNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.ShortAsNumber) RedirectExtendedCommunityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.redirect.extended.community.RedirectExtendedCommunityBuilder)

Example 2 with RedirectExtendedCommunityBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.redirect.extended.community.RedirectExtendedCommunityBuilder in project bgpcep by opendaylight.

the class FSExtendedCommunitiesTest method testRedirect2bParser.

@Test
public void testRedirect2bParser() throws BGPDocumentedException, BGPParsingException {
    final RedirectExtendedCommunityCase redirect = new 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 ExtendedCommunities parsed = this.registry.parseExtendedCommunity(Unpooled.copiedBuffer(REDIRECT_AS_2BYTES));
    Assert.assertEquals(expected, parsed);
}
Also used : RedirectExtendedCommunityCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update.attributes.extended.communities.extended.community.RedirectExtendedCommunityCase) ExtendedCommunities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunities) RedirectExtendedCommunityCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update.attributes.extended.communities.extended.community.RedirectExtendedCommunityCaseBuilder) ShortAsNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.ShortAsNumber) RedirectExtendedCommunityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.redirect.extended.community.RedirectExtendedCommunityBuilder) ExtendedCommunitiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunitiesBuilder) Test(org.junit.Test)

Example 3 with RedirectExtendedCommunityBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.redirect.extended.community.RedirectExtendedCommunityBuilder 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());
}
Also used : ShortAsNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.ShortAsNumber) ByteBuf(io.netty.buffer.ByteBuf) RedirectExtendedCommunityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.redirect.extended.community.RedirectExtendedCommunityBuilder) ExtendedCommunities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunities) RedirectExtendedCommunityCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update.attributes.extended.communities.extended.community.RedirectExtendedCommunityCaseBuilder) ExtendedCommunitiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunitiesBuilder) Test(org.junit.Test)

Aggregations

RedirectExtendedCommunityBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.redirect.extended.community.RedirectExtendedCommunityBuilder)3 RedirectExtendedCommunityCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update.attributes.extended.communities.extended.community.RedirectExtendedCommunityCaseBuilder)3 ShortAsNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.ShortAsNumber)3 Test (org.junit.Test)2 ExtendedCommunities (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunities)2 ExtendedCommunitiesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunitiesBuilder)2 ByteBuf (io.netty.buffer.ByteBuf)1 RedirectExtendedCommunityCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update.attributes.extended.communities.extended.community.RedirectExtendedCommunityCase)1