Search in sources :

Example 1 with EncapsulationCase

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

the class EncapsulationEC method serializeExtendedCommunity.

@Override
public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf body) {
    Preconditions.checkArgument(extendedCommunity instanceof EncapsulationCase, "The extended community %s is not EncapsulationCase type.", extendedCommunity);
    final EncapsulationExtendedCommunity encap = ((EncapsulationCase) extendedCommunity).getEncapsulationExtendedCommunity();
    body.writeZero(RESERVED_SIZE);
    body.writeShort(encap.getTunnelType().getIntValue());
}
Also used : EncapsulationCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.extended.community.EncapsulationCase) EncapsulationExtendedCommunity(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.extended.community.encapsulation._case.EncapsulationExtendedCommunity)

Example 2 with EncapsulationCase

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

the class EncapsulationECTest method testParser.

@Test
public void testParser() throws BGPParsingException, BGPDocumentedException {
    final ByteBuf buffer = Unpooled.buffer(COMMUNITY_VALUE_SIZE);
    final EncapsulationCase expected = new EncapsulationCaseBuilder().setEncapsulationExtendedCommunity(new EncapsulationExtendedCommunityBuilder().setTunnelType(TUNNEL_TYPE).build()).build();
    this.parser.serializeExtendedCommunity(expected, buffer);
    assertArrayEquals(RESULT, ByteArray.getAllBytes(buffer));
    final ExtendedCommunity result = this.parser.parseExtendedCommunity(Unpooled.wrappedBuffer(RESULT));
    assertEquals(expected, result);
}
Also used : EncapsulationExtendedCommunityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.extended.community.encapsulation._case.EncapsulationExtendedCommunityBuilder) EncapsulationCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.extended.community.EncapsulationCase) EncapsulationCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.extended.community.EncapsulationCaseBuilder) ExtendedCommunity(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.ExtendedCommunity) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Aggregations

EncapsulationCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.extended.community.EncapsulationCase)2 ByteBuf (io.netty.buffer.ByteBuf)1 Test (org.junit.Test)1 ExtendedCommunity (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.ExtendedCommunity)1 EncapsulationCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.extended.community.EncapsulationCaseBuilder)1 EncapsulationExtendedCommunity (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.extended.community.encapsulation._case.EncapsulationExtendedCommunity)1 EncapsulationExtendedCommunityBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.extended.community.encapsulation._case.EncapsulationExtendedCommunityBuilder)1