use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.ClusterIdentifier in project bgpcep by opendaylight.
the class SetClusterIdPrependHandler method prependClusterId.
private static Attributes prependClusterId(final Attributes attributes, final ClusterIdentifier clusterId) {
final AttributesBuilder newAtt = new AttributesBuilder(attributes);
final List<ClusterIdentifier> newClusterList = new ArrayList<>();
newClusterList.add(clusterId);
if (attributes.getClusterId() != null && !attributes.getClusterId().getCluster().isEmpty()) {
final List<ClusterIdentifier> oldList = attributes.getClusterId().getCluster();
newClusterList.addAll(oldList);
}
return newAtt.setClusterId(new ClusterIdBuilder().setCluster(newClusterList).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.ClusterIdentifier in project bgpcep by opendaylight.
the class ClusterIdAttributeParser method parseAttribute.
@Override
public void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder, final RevisedErrorHandling errorHandling, final PeerSpecificParserConstraint constraint) throws BGPDocumentedException, BGPTreatAsWithdrawException {
if (errorHandling == RevisedErrorHandling.EXTERNAL) {
// RFC7606 section 7.10
LOG.debug("Discarded CLUSTER_LIST attribute from external peer");
return;
}
final int readable = buffer.readableBytes();
if (readable == 0 && errorHandling != RevisedErrorHandling.NONE) {
throw new BGPTreatAsWithdrawException(BGPError.ATTR_LENGTH_ERROR, "Empty CLUSTER_LIST attribute");
}
if (readable % Ipv4Util.IP4_LENGTH != 0) {
throw errorHandling.reportError(BGPError.ATTR_LENGTH_ERROR, "Length of CLUSTER_LIST should be a multiple of 4, but is %s", readable);
}
final int count = readable / Ipv4Util.IP4_LENGTH;
final List<ClusterIdentifier> list = new ArrayList<>(count);
for (int i = 0; i < count; ++i) {
list.add(new ClusterIdentifier(Ipv4Util.addressForByteBuf(buffer)));
}
builder.setClusterId(new ClusterIdBuilder().setCluster(list).build());
}
Aggregations