use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.extended.community.encapsulation._case.EncapsulationExtendedCommunity 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.rev130919.extended.community.extended.community.encapsulation._case.EncapsulationExtendedCommunity 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());
}
Aggregations