use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.ExtendedCommunity in project bgpcep by opendaylight.
the class SourceASHandler method parseExtendedCommunity.
@Override
public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer) {
final SourceAsExtendedCommunityBuilder builder = new SourceAsExtendedCommunityBuilder();
builder.setGlobalAdministrator(new ShortAsNumber(Uint32.valueOf(buffer.readUnsignedShort())));
buffer.skipBytes(AS_LOCAL_ADMIN_LENGTH);
return new SourceAsExtendedCommunityCaseBuilder().setSourceAsExtendedCommunity(builder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.ExtendedCommunity in project bgpcep by opendaylight.
the class SourceASHandler method serializeExtendedCommunity.
@Override
public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf body) {
Preconditions.checkArgument(extendedCommunity instanceof SourceAsExtendedCommunityCase, "The extended community %s is not SourceAsExtendedCommunityCase type.", extendedCommunity);
final SourceAsExtendedCommunity excomm = ((SourceAsExtendedCommunityCase) extendedCommunity).getSourceAsExtendedCommunity();
body.writeShort(excomm.getGlobalAdministrator().getValue().intValue());
body.writeInt(LOCAL_ADMIN);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.ExtendedCommunity 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);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.ExtendedCommunity in project bgpcep by opendaylight.
the class VrfRouteImportHandlerTest method testHandler.
@Test
public void testHandler() {
final VrfRouteImportExtendedCommunityCase expected = new VrfRouteImportExtendedCommunityCaseBuilder().setVrfRouteImportExtendedCommunity(new VrfRouteImportExtendedCommunityBuilder().setInet4SpecificExtendedCommunityCommon(new Inet4SpecificExtendedCommunityCommonBuilder().setGlobalAdministrator(new Ipv4AddressNoZone("12.51.2.5")).setLocalAdministrator(new byte[] { 21, 45 }).build()).build()).build();
final ExtendedCommunity exComm = this.handler.parseExtendedCommunity(Unpooled.copiedBuffer(INPUT));
assertEquals(expected, exComm);
final ByteBuf output = Unpooled.buffer(INPUT.length);
this.handler.serializeExtendedCommunity(expected, output);
Assert.assertArrayEquals(INPUT, output.array());
assertEquals(11, this.handler.getSubType());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.ExtendedCommunity in project bgpcep by opendaylight.
the class RouteTargetAsTwoOctetEcHandlerTest method testHandler.
@Test
public void testHandler() throws BGPDocumentedException, BGPParsingException {
final RouteTargetAsTwoOctetEcHandler handler = new RouteTargetAsTwoOctetEcHandler();
final RouteTargetExtendedCommunityCase expected = new RouteTargetExtendedCommunityCaseBuilder().setRouteTargetExtendedCommunity(new RouteTargetExtendedCommunityBuilder().setGlobalAdministrator(new ShortAsNumber(Uint32.valueOf(35))).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());
}
Aggregations