use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Community in project bgpcep by opendaylight.
the class RouteTargetAsTwoOctetEcHandler method serializeExtendedCommunity.
@Override
public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) {
Preconditions.checkArgument(extendedCommunity instanceof RouteTargetExtendedCommunityCase, "The extended community %s is not RouteTargetExtendedCommunityCase type.", extendedCommunity);
final RouteTargetExtendedCommunity routeTarget = ((RouteTargetExtendedCommunityCase) extendedCommunity).getRouteTargetExtendedCommunity();
ByteBufWriteUtil.writeUnsignedShort(Ints.checkedCast(routeTarget.getGlobalAdministrator().getValue()), byteAggregator);
byteAggregator.writeBytes(routeTarget.getLocalAdministrator());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Community in project bgpcep by opendaylight.
the class RouteTargetIpv4EcHandler method serializeExtendedCommunity.
@Override
public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) {
Preconditions.checkArgument(extendedCommunity instanceof RouteTargetIpv4Case, "The extended community %s is not RouteTargetAsTwoOctetCase type.", extendedCommunity);
final RouteTargetIpv4 routeTarget = ((RouteTargetIpv4Case) extendedCommunity).getRouteTargetIpv4();
ByteBufWriteUtil.writeIpv4Address(routeTarget.getGlobalAdministrator(), byteAggregator);
ByteBufWriteUtil.writeUnsignedShort(routeTarget.getLocalAdministrator(), byteAggregator);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Community in project bgpcep by opendaylight.
the class CommunitiesAttributeParser method serializeAttribute.
@Override
public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object.");
final List<Communities> communities = ((Attributes) attribute).getCommunities();
if (communities == null || communities.isEmpty()) {
return;
}
final ByteBuf communitiesBuffer = Unpooled.buffer();
for (final Community community : communities) {
communitiesBuffer.writeShort(community.getAsNumber().getValue().shortValue());
communitiesBuffer.writeShort(community.getSemantics().shortValue());
}
AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL | AttributeUtil.TRANSITIVE, TYPE, communitiesBuffer, byteAggregator);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Community in project bgpcep by opendaylight.
the class MACMobExtCom method serializeExtendedCommunity.
@Override
public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) {
Preconditions.checkArgument(extendedCommunity instanceof MacMobilityExtendedCommunityCase, "The extended community %s is not MacMobilityExtendedCommunityCase type.", extendedCommunity);
final MacMobilityExtendedCommunity extCom = ((MacMobilityExtendedCommunityCase) extendedCommunity).getMacMobilityExtendedCommunity();
byteAggregator.writeBoolean(extCom.getStatic());
byteAggregator.writeZero(RESERVED);
byteAggregator.writeInt(extCom.getSeqNumber().intValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Community in project bgpcep by opendaylight.
the class Layer2AttributesExtCom method serializeExtendedCommunity.
@Override
public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf body) {
Preconditions.checkArgument(extendedCommunity instanceof Layer2AttributesExtendedCommunityCase, "The extended community %s is not EsImportRouteExtendedCommunityCaseCase type.", extendedCommunity);
final Layer2AttributesExtendedCommunity extCom = ((Layer2AttributesExtendedCommunityCase) extendedCommunity).getLayer2AttributesExtendedCommunity();
final BitArray flags = new BitArray(FLAGS_SIZE);
flags.set(PRIMARY_PE_OFFSET, extCom.getPrimaryPe());
flags.set(BACKUP_PE_OFFSET, extCom.getBackupPe());
flags.set(CONTROL_WORD_OFFSET, extCom.getControlWord());
final byte[] res = flags.array();
byte aux = 0;
final OperationalMode modeOfOperation = extCom.getModeOfOperation();
if (modeOfOperation != null) {
aux = UnsignedBytes.checkedCast(modeOfOperation.getIntValue());
aux = (byte) (aux << THREE_BITS_SHIFT);
res[res.length - 1] = (byte) (res[res.length - 1] | aux);
}
final NormalizationType normalizationType = extCom.getOperatingPer();
if (normalizationType != null) {
aux = UnsignedBytes.checkedCast(normalizationType.getIntValue());
aux = (byte) (aux << FIVE_BITS_SHIFT);
res[res.length - 1] = (byte) (res[res.length - 1] | aux);
}
body.writeShort(res[res.length - 1]);
ByteBufUtils.writeOrZero(body, extCom.getL2Mtu());
body.writeZero(RESERVED);
}
Aggregations