use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ClusterIdBuilder 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());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ClusterIdBuilder in project bgpcep by opendaylight.
the class ClusterIdAttributeParserTest method testParseEmptyAttribute.
@Test
public void testParseEmptyAttribute() {
final Attributes clusterId = new AttributesBuilder().setClusterId(new ClusterIdBuilder().build()).build();
final ByteBuf output = Unpooled.buffer();
this.parser.serializeAttribute(clusterId, output);
assertEquals(Unpooled.buffer(), output);
}
Aggregations