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 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);
}
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 EncapsulationEC method parseExtendedCommunity.
@Override
public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException {
Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
Preconditions.checkArgument(buffer.readableBytes() == CONTENT_SIZE, "Wrong length of array of bytes. Passed: " + buffer.readableBytes() + ".");
buffer.skipBytes(RESERVED_SIZE);
final EncapsulationExtendedCommunity encap = new EncapsulationExtendedCommunityBuilder().setTunnelType(EncapsulationTunnelType.forValue(buffer.readUnsignedShort())).build();
return new EncapsulationCaseBuilder().setEncapsulationExtendedCommunity(encap).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 LinkBandwidthEC method serializeExtendedCommunity.
@Override
public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf body) {
Preconditions.checkArgument(extendedCommunity instanceof LinkBandwidthCase, "The extended community %s is not LinkBandwidthCase type.", extendedCommunity);
final LinkBandwidthExtendedCommunity lb = ((LinkBandwidthCase) extendedCommunity).getLinkBandwidthExtendedCommunity();
body.writeShort(AS_TRANS);
ByteBufWriteUtil.writeFloat32(lb.getBandwidth(), body);
}
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 RouteTargetIpv4EcHandlerTest method testHandler.
@Test
public void testHandler() throws BGPDocumentedException, BGPParsingException {
final RouteTargetIpv4EcHandler handler = new RouteTargetIpv4EcHandler();
final RouteTargetIpv4Case expected = new RouteTargetIpv4CaseBuilder().setRouteTargetIpv4(new RouteTargetIpv4Builder().setGlobalAdministrator(new Ipv4AddressNoZone("12.51.2.5")).setLocalAdministrator(Uint16.valueOf(5421)).build()).build();
final ExtendedCommunity exComm = handler.parseExtendedCommunity(Unpooled.copiedBuffer(INPUT));
assertEquals(expected, exComm);
final ByteBuf output = Unpooled.buffer(INPUT.length);
handler.serializeExtendedCommunity(expected, output);
assertArrayEquals(INPUT, output.array());
}
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 Ipv4SpecificEcHandlerTest method testHandle.
@Test
public void testHandle() {
final Ipv4SpecificEcHandler handler = new Ipv4SpecificEcHandler();
final Inet4SpecificExtendedCommunityCase expected = new Inet4SpecificExtendedCommunityCaseBuilder().setInet4SpecificExtendedCommunity(new Inet4SpecificExtendedCommunityBuilder().setInet4SpecificExtendedCommunityCommon(new Inet4SpecificExtendedCommunityCommonBuilder().setGlobalAdministrator(new Ipv4AddressNoZone("12.51.2.5")).setLocalAdministrator(new byte[] { 21, 45 }).build()).build()).build();
final ExtendedCommunity exComm = handler.parseExtendedCommunity(Unpooled.copiedBuffer(INPUT));
assertEquals(expected, exComm);
final ByteBuf output = Unpooled.buffer(INPUT.length);
handler.serializeExtendedCommunity(expected, output);
assertArrayEquals(INPUT, output.array());
}
Aggregations