use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ExcludeRouteSubobjects.Attribute in project bgpcep by opendaylight.
the class SimpleAttributeRegistry method processUnrecognized.
private void processUnrecognized(final BitArray flags, final int type, final ByteBuf buffer, final int len) throws BGPDocumentedException {
if (!flags.get(OPTIONAL_BIT)) {
throw new BGPDocumentedException("Well known attribute not recognized.", BGPError.WELL_KNOWN_ATTR_NOT_RECOGNIZED);
}
final Uint8 typeVal = Uint8.valueOf(type);
final UnrecognizedAttributes unrecognizedAttribute = new UnrecognizedAttributesBuilder().withKey(new UnrecognizedAttributesKey(typeVal)).setPartial(flags.get(PARTIAL_BIT)).setTransitive(flags.get(TRANSITIVE_BIT)).setType(typeVal).setValue(ByteArray.readBytes(buffer, len)).build();
this.unrecognizedAttributes.add(unrecognizedAttribute);
LOG.debug("Unrecognized attribute were parsed: {}", unrecognizedAttribute);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ExcludeRouteSubobjects.Attribute in project bgpcep by opendaylight.
the class XROSrlgSubobjectParser method serializeSubobject.
@Override
public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
final SubobjectType type = subobject.getSubobjectType();
checkArgument(type instanceof SrlgCase, "Unknown subobject instance. Passed %s. Needed SrlgCase.", type.getClass());
final SrlgSubobject specObj = ((SrlgCase) type).getSrlg();
final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
final SrlgId srlgId = specObj.getSrlgId();
checkArgument(srlgId != null, "SrlgId is mandatory.");
ByteBufUtils.write(body, srlgId.getValue());
final Attribute attribute = subobject.getAttribute();
checkArgument(attribute != null, "Attribute is mandatory.");
body.writeByte(0);
body.writeByte(attribute.getIntValue());
XROSubobjectUtil.formatSubobject(TYPE, subobject.getMandatory(), body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ExcludeRouteSubobjects.Attribute in project bgpcep by opendaylight.
the class XROUnnumberedInterfaceSubobjectParser method serializeSubobject.
@Override
public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
final SubobjectType type = subobject.getSubobjectType();
checkArgument(type instanceof UnnumberedCase, "Unknown subobject instance. Passed %s. Needed UnnumberedCase.", type.getClass());
final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
body.writeZero(RESERVED);
final Attribute attribute = subobject.getAttribute();
body.writeByte(attribute != null ? attribute.getIntValue() : 0);
serializeUnnumeredInterface(((UnnumberedCase) type).getUnnumbered(), body);
XROSubobjectUtil.formatSubobject(TYPE, subobject.getMandatory(), body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ExcludeRouteSubobjects.Attribute in project bgpcep by opendaylight.
the class XROIpv6PrefixSubobjectParser method serializeSubobject.
static void serializeSubobject(final ByteBuf buffer, final SubobjectContainer subobject, final Ipv6Prefix ipv6Prefix) {
final ByteBuf body = Unpooled.buffer(CONTENT6_LENGTH);
Ipv6Util.writeIpv6Prefix(ipv6Prefix, body);
final Attribute attribute = subobject.getAttribute();
checkArgument(attribute != null, "Attribute is mandatory.");
body.writeByte(attribute.getIntValue());
XROSubobjectUtil.formatSubobject(TYPE, subobject.getMandatory(), body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ExcludeRouteSubobjects.Attribute in project bgpcep by opendaylight.
the class PEDistinguisherLabelsAttributeHandler method parseAttribute.
@Override
public void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder, final RevisedErrorHandling errorHandling, final PeerSpecificParserConstraint constraint) throws BGPTreatAsWithdrawException {
final int readable = buffer.readableBytes();
if (readable == 0) {
return;
}
final boolean isIpv4;
final int count;
if (readable % 7 == 0) {
count = readable / 7;
isIpv4 = true;
} else if (readable % 19 == 0) {
count = readable / 19;
isIpv4 = false;
} else {
// as though all the routes contained in this Update had been withdrawn.
throw new BGPTreatAsWithdrawException(BGPError.MALFORMED_ATTR_LIST, "PE Distinguisher Labels has incorrect length %s", readable);
}
final List<PeDistinguisherLabelAttribute> list = new ArrayList<>(count);
for (int i = 0; i < count; ++i) {
final PeDistinguisherLabelAttributeBuilder attribute = new PeDistinguisherLabelAttributeBuilder();
if (isIpv4) {
attribute.setPeAddress(new IpAddressNoZone(Ipv4Util.addressForByteBuf(buffer)));
} else {
attribute.setPeAddress(new IpAddressNoZone(Ipv6Util.addressForByteBuf(buffer)));
}
attribute.setMplsLabel(MplsLabelUtil.mplsLabelForByteBuf(buffer));
list.add(attribute.build());
}
builder.addAugmentation(new PeDistinguisherLabelsAttributeAugmentationBuilder().setPeDistinguisherLabelsAttribute(new PeDistinguisherLabelsAttributeBuilder().setPeDistinguisherLabelAttribute(list).build()).build());
}
Aggregations