use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.xro.Subobject 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);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.xro.Subobject in project bgpcep by opendaylight.
the class RequiredAttributesObjectParser method localParseObject.
@Override
protected RsvpTeObject localParseObject(final ByteBuf byteBuf) throws RSVPParsingException {
final LspRequiredAttributesObjectBuilder builder = new LspRequiredAttributesObjectBuilder();
final List<SubobjectContainer> subObjectList = new ArrayList<>();
while (byteBuf.isReadable()) {
final int type = byteBuf.readUnsignedShort();
final int length = byteBuf.readUnsignedShort();
final ByteBuf value = byteBuf.readSlice(length);
final SubobjectContainerBuilder subObj = new SubobjectContainerBuilder();
if (type == AttributesObjectParser.FLAG_TLV_TYPE) {
subObj.setLspSubobject(new FlagsTlvBuilder().setFlagContainer(AttributesObjectParser.parseFlag(value)).build());
} else {
LOG.warn("Lsp Attributes Subobject type {} not supported", type);
}
subObjectList.add(subObj.build());
}
return builder.setLspAttributesObject(new LspAttributesObjectBuilder().setSubobjectContainer(subObjectList).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.xro.Subobject in project bgpcep by opendaylight.
the class RequiredAttributesObjectParser method localSerializeObject.
@Override
public void localSerializeObject(final RsvpTeObject teLspObject, final ByteBuf byteAggregator) {
Preconditions.checkArgument(teLspObject instanceof LspRequiredAttributesObject, "LspAttributesObject is mandatory.");
final LspRequiredAttributesObject lspAttributesObject = (LspRequiredAttributesObject) teLspObject;
final ByteBuf bufferAux = Unpooled.buffer();
int lenght = 0;
for (final SubobjectContainer subObject : lspAttributesObject.getLspAttributesObject().getSubobjectContainer()) {
final LspSubobject lspSubonject = subObject.getLspSubobject();
if (lspSubonject instanceof FlagsTlv) {
final ByteBuf flagTLVValue = Unpooled.buffer();
final List<FlagContainer> flagList = ((FlagsTlv) lspSubonject).getFlagContainer();
lenght = AttributesObjectParser.FLAG_TLV_SIZE * flagList.size();
AttributesObjectParser.serializeFlag(flagList, flagTLVValue);
AttributesObjectParser.serializeTLV(AttributesObjectParser.FLAG_TLV_TYPE, lenght, flagTLVValue, bufferAux);
lenght += AttributesObjectParser.TLV_HEADER_SIZE;
}
}
serializeAttributeHeader(lenght, CLASS_NUM, CTYPE, byteAggregator);
byteAggregator.writeBytes(bufferAux);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.xro.Subobject in project bgpcep by opendaylight.
the class EROSubobjectListParser method parseList.
public List<SubobjectContainer> parseList(final ByteBuf buffer) throws RSVPParsingException {
// Explicit approval of empty ERO
Preconditions.checkArgument(buffer != null, "Array of bytes is mandatory. Can't be null.");
final List<SubobjectContainer> subs = new ArrayList<>();
while (buffer.isReadable()) {
final boolean loose = (buffer.getUnsignedByte(buffer.readerIndex()) & (1 << Values.FIRST_BIT_OFFSET)) != 0;
final int type = (buffer.readUnsignedByte() & Values.BYTE_MAX_VALUE_BYTES) & ~(1 << Values.FIRST_BIT_OFFSET);
final int length = buffer.readUnsignedByte() - HEADER_LENGTH;
if (length > buffer.readableBytes()) {
throw new RSVPParsingException("Wrong length specified. Passed: " + length + "; Expected: <= " + buffer.readableBytes());
}
LOG.debug("Attempt to parse subobject from bytes: {}", ByteBufUtil.hexDump(buffer));
final SubobjectContainer sub = this.subobjReg.parseSubobject(type, buffer.readSlice(length), loose);
if (sub == null) {
LOG.warn("Unknown subobject type: {}. Ignoring subobject.", type);
} else {
LOG.debug("Subobject was parsed. {}", sub);
subs.add(sub);
}
}
return subs;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.xro.Subobject in project bgpcep by opendaylight.
the class XROSubobjectListParser method parseList.
public List<SubobjectContainer> parseList(final ByteBuf byteBuf) throws RSVPParsingException {
final List<SubobjectContainer> subs = new ArrayList<>();
while (byteBuf.isReadable()) {
final boolean mandatory = (byteBuf.getUnsignedByte(byteBuf.readerIndex()) & (1 << Values.FIRST_BIT_OFFSET)) != 0;
final int type = UnsignedBytes.checkedCast((byteBuf.readUnsignedByte() & Values.BYTE_MAX_VALUE_BYTES) & ~(1 << Values.FIRST_BIT_OFFSET));
final int length = byteBuf.readUnsignedByte() - HEADER_LENGHT;
if (length > byteBuf.readableBytes()) {
throw new RSVPParsingException("Wrong length specified. Passed: " + length + "; Expected: <= " + byteBuf.readableBytes());
}
LOG.debug("Attempt to parse subobject from bytes: {}", ByteBufUtil.hexDump(byteBuf));
final SubobjectContainer sub = this.subobjReg.parseSubobject(type, byteBuf.readSlice(length), mandatory);
if (sub == null) {
LOG.warn("Unknown subobject type: {}. Ignoring subobject.", type);
} else {
LOG.debug("Subobject was parsed. {}", sub);
subs.add(sub);
}
}
return subs;
}
Aggregations