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 NonTransitiveAttributesFilterHandler method filterAttributes.
private static Attributes filterAttributes(final Attributes attributes) {
final AttributesBuilder builder = new AttributesBuilder().setCNextHop(attributes.getCNextHop()).setOrigin(attributes.getOrigin()).setAsPath(attributes.getAsPath()).setCommunities(attributes.getCommunities());
final Map<UnrecognizedAttributesKey, UnrecognizedAttributes> oldAtt = attributes.getUnrecognizedAttributes();
if (oldAtt != null) {
// TODO: consider using Maps.filterValues(attributes.getUnrecognizedAttributes(),
// UnrecognizedAttributes::isTransitive)) ?
builder.setUnrecognizedAttributes(attributes.getUnrecognizedAttributes().values().stream().filter(UnrecognizedAttributes::getTransitive).collect(ImmutableMap.toImmutableMap(UnrecognizedAttributes::key, Function.identity())));
}
final List<ExtendedCommunities> oldExt = attributes.getExtendedCommunities();
if (oldExt != null) {
builder.setExtendedCommunities(oldExt.stream().filter(ExtendedCommunity::getTransitive).collect(Collectors.toList()));
}
return builder.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 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();
RouteTargetExtendedCommunityHandler.serialize(routeTarget, 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 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());
}
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 parseExtendedCommunity.
@Override
public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException {
buffer.skipBytes(AS_TRANS_LENGTH);
final LinkBandwidthExtendedCommunity lb = new LinkBandwidthExtendedCommunityBuilder().setBandwidth(new Bandwidth(ByteArray.readBytes(buffer, BANDWIDTH_SIZE))).build();
return new LinkBandwidthCaseBuilder().setLinkBandwidthExtendedCommunity(lb).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 RouteOriginAsTwoOctetEcHandler method serializeExtendedCommunity.
@Override
public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) {
Preconditions.checkArgument(extendedCommunity instanceof RouteOriginExtendedCommunityCase, "The extended community %s is not RouteOriginExtendedCommunity type.", extendedCommunity);
final RouteOriginExtendedCommunity routeOrigin = ((RouteOriginExtendedCommunityCase) extendedCommunity).getRouteOriginExtendedCommunity();
byteAggregator.writeShort(routeOrigin.getGlobalAdministrator().getValue().intValue());
byteAggregator.writeBytes(routeOrigin.getLocalAdministrator());
}
Aggregations