use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.list.SubobjectContainer in project bgpcep by opendaylight.
the class SEROBasicProtectionSubobjectParser method parseSubobject.
@Override
public SubobjectContainer parseSubobject(final ByteBuf buffer, final boolean loose) throws RSVPParsingException {
Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
final SubobjectContainerBuilder builder = new SubobjectContainerBuilder();
builder.setLoose(loose);
// skip reserved
buffer.readByte();
final short cType = buffer.readUnsignedByte();
final ProtectionSubobject prot = parseCommonProtectionBody(cType, buffer);
if (cType == CTYPE) {
builder.setSubobjectType(new BasicProtectionCaseBuilder().setBasicProtection(new BasicProtectionBuilder().setProtectionSubobject(prot).build()).build());
} else if (cType == SERODynamicProtectionSubobjectParser.CTYPE) {
builder.setSubobjectType(new DynamicControlProtectionCaseBuilder().setDynamicControlProtection(new DynamicControlProtectionBuilder().setProtectionSubobject(prot).build()).build());
}
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.list.SubobjectContainer in project bgpcep by opendaylight.
the class EROExplicitExclusionRouteSubobjectParser method parseSubobject.
@Override
public SubobjectContainer parseSubobject(final ByteBuf buffer, final boolean loose) throws RSVPParsingException {
Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
final SubobjectContainerBuilder builder = new SubobjectContainerBuilder();
builder.setLoose(loose);
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.exclude.route.object.exclude.route.object.SubobjectContainer> list = localParseSubobject(buffer);
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.exrs._case.exrs.Exrs> exrss = new ArrayList<>();
for (final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.exclude.route.object.exclude.route.object.SubobjectContainer s : list) {
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.exrs._case.exrs.ExrsBuilder b = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.exrs._case.exrs.ExrsBuilder();
b.setAttribute(s.getAttribute());
b.setMandatory(s.getMandatory());
b.setSubobjectType(s.getSubobjectType());
exrss.add(b.build());
}
builder.setSubobjectType(new ExrsCaseBuilder().setExrs(new ExrsBuilder().setExrs(exrss).build()).build());
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.list.SubobjectContainer in project bgpcep by opendaylight.
the class RROLabelSubobjectParser method serializeSubobject.
@Override
public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
requireNonNull(subobject.getSubobjectType(), "Subobject type cannot be empty.");
final Label label = ((LabelCase) subobject.getSubobjectType()).getLabel();
final ByteBuf body = Unpooled.buffer();
this.registry.serializeLabel(label.getUniDirectional(), label.getGlobal(), label.getLabelType(), body);
RROSubobjectUtil.formatSubobject(TYPE, body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.list.SubobjectContainer in project bgpcep by opendaylight.
the class SecondaryRecordRouteObjectParser method localParseObject.
@Override
protected RsvpTeObject localParseObject(final ByteBuf byteBuf) throws RSVPParsingException {
final SecondaryRecordRouteObjectBuilder srro = new SecondaryRecordRouteObjectBuilder();
final List<SubobjectContainer> sbo = parseList(byteBuf);
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary._record.route.object.secondary._record.route.object.SubobjectContainer> srroSbo = sbo.stream().map(so -> new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary._record.route.object.secondary._record.route.object.SubobjectContainerBuilder().setProtectionAvailable(so.getProtectionAvailable()).setProtectionInUse(so.getProtectionInUse()).setSubobjectType(so.getSubobjectType()).build()).collect(Collectors.toList());
return srro.setSubobjectContainer(srroSbo).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.list.SubobjectContainer in project bgpcep by opendaylight.
the class AttributesObjectParser method localSerializeObject.
@Override
public void localSerializeObject(final RsvpTeObject teLspObject, final ByteBuf byteAggregator) {
Preconditions.checkArgument(teLspObject instanceof LspAttributesObject, "LspAttributesObject is mandatory.");
final LspAttributesObject lspAttributesObject = (LspAttributesObject) teLspObject;
final ByteBuf bufferAux = Unpooled.buffer();
int length = 0;
for (final SubobjectContainer subObject : lspAttributesObject.getSubobjectContainer()) {
final LspSubobject lspSubonject = subObject.getLspSubobject();
if (lspSubonject instanceof FlagsTlv) {
final ByteBuf flagTLVValue = Unpooled.buffer();
final List<FlagContainer> flagList = ((FlagsTlv) lspSubonject).getFlagContainer();
length = FLAG_TLV_SIZE * flagList.size();
serializeFlag(flagList, flagTLVValue);
serializeTLV(FLAG_TLV_TYPE, length, flagTLVValue, bufferAux);
length += TLV_HEADER_SIZE;
}
}
serializeAttributeHeader(length, CLASS_NUM, CTYPE, byteAggregator);
byteAggregator.writeBytes(bufferAux);
}
Aggregations