Search in sources :

Example 1 with RouteOriginExtendedCommunityCase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.extended.community.RouteOriginExtendedCommunityCase in project bgpcep by opendaylight.

the class RouteOriginAsTwoOctetEcHandlerTest method testHandler.

@Test
public void testHandler() throws BGPDocumentedException, BGPParsingException {
    final RouteOriginAsTwoOctetEcHandler handler = new RouteOriginAsTwoOctetEcHandler();
    final RouteOriginExtendedCommunityCase expected = new RouteOriginExtendedCommunityCaseBuilder().setRouteOriginExtendedCommunity(new RouteOriginExtendedCommunityBuilder().setGlobalAdministrator(new ShortAsNumber(24L)).setLocalAdministrator(new byte[] { 4, 2, 8, 7 }).build()).build();
    final ExtendedCommunity exComm = handler.parseExtendedCommunity(Unpooled.copiedBuffer(INPUT));
    Assert.assertEquals(expected, exComm);
    final ByteBuf output = Unpooled.buffer(INPUT.length);
    handler.serializeExtendedCommunity(expected, output);
    Assert.assertArrayEquals(INPUT, output.array());
}
Also used : RouteOriginExtendedCommunityCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.extended.community.RouteOriginExtendedCommunityCaseBuilder) ExtendedCommunity(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.ExtendedCommunity) RouteOriginExtendedCommunityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.extended.community.route.origin.extended.community._case.RouteOriginExtendedCommunityBuilder) ShortAsNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ShortAsNumber) ByteBuf(io.netty.buffer.ByteBuf) RouteOriginExtendedCommunityCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.extended.community.RouteOriginExtendedCommunityCase) Test(org.junit.Test)

Example 2 with RouteOriginExtendedCommunityCase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.extended.community.RouteOriginExtendedCommunityCase in project bgpcep by opendaylight.

the class RouteOriginAsTwoOctetEcHandler method serializeExtendedCommunity.

@Override
public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) {
    Preconditions.checkArgument(extendedCommunity instanceof RouteOriginExtendedCommunityCase, "The extended community %s is not RouteOriginExtendedCommunity type.", extendedCommunity);
    final RouteOriginExtendedCommunity routeOrigin = ((RouteOriginExtendedCommunityCase) extendedCommunity).getRouteOriginExtendedCommunity();
    ByteBufWriteUtil.writeUnsignedShort(Ints.checkedCast(routeOrigin.getGlobalAdministrator().getValue()), byteAggregator);
    byteAggregator.writeBytes(routeOrigin.getLocalAdministrator());
}
Also used : RouteOriginExtendedCommunity(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.extended.community.route.origin.extended.community._case.RouteOriginExtendedCommunity) RouteOriginExtendedCommunityCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.extended.community.RouteOriginExtendedCommunityCase)

Example 3 with RouteOriginExtendedCommunityCase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.extended.community.RouteOriginExtendedCommunityCase 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(54L)).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);
    final ExtendedCommunities parsed = attBuilder.getExtendedCommunities().get(0);
    Assert.assertEquals(expected, parsed);
    final ByteBuf output = Unpooled.buffer(INPUT.length);
    this.handler.serializeAttribute(attBuilder.build(), output);
    Assert.assertArrayEquals(Bytes.concat(new byte[] { (byte) 192, 16, 8 }, INPUT), ByteArray.readAllBytes(output));
}
Also used : RouteOriginExtendedCommunityCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.extended.community.RouteOriginExtendedCommunityCaseBuilder) ExtendedCommunities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ExtendedCommunities) RouteOriginExtendedCommunityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.extended.community.route.origin.extended.community._case.RouteOriginExtendedCommunityBuilder) ShortAsNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ShortAsNumber) ByteBuf(io.netty.buffer.ByteBuf) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder) RouteOriginExtendedCommunityCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.extended.community.RouteOriginExtendedCommunityCase) ExtendedCommunitiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ExtendedCommunitiesBuilder) Test(org.junit.Test)

Aggregations

RouteOriginExtendedCommunityCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.extended.community.RouteOriginExtendedCommunityCase)3 ByteBuf (io.netty.buffer.ByteBuf)2 Test (org.junit.Test)2 ShortAsNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ShortAsNumber)2 RouteOriginExtendedCommunityCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.extended.community.RouteOriginExtendedCommunityCaseBuilder)2 RouteOriginExtendedCommunityBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.extended.community.route.origin.extended.community._case.RouteOriginExtendedCommunityBuilder)2 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)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 ExtendedCommunity (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.ExtendedCommunity)1 RouteOriginExtendedCommunity (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.extended.community.route.origin.extended.community._case.RouteOriginExtendedCommunity)1