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 localParseObject.
@Override
protected RsvpTeObject localParseObject(final ByteBuf byteBuf) throws RSVPParsingException {
final LspAttributesObjectBuilder builder = new LspAttributesObjectBuilder();
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 == FLAG_TLV_TYPE) {
subObj.setLspSubobject(new FlagsTlvBuilder().setFlagContainer(parseFlag(value)).build());
} else {
LOG.warn("Lsp Attributes Subobject type {} not supported", type);
}
subObjectList.add(subObj.build());
}
return builder.setSubobjectContainer(subObjectList).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 SimpleXROSubobjectRegistryTest method testUnrecognizedType.
@Test
public void testUnrecognizedType() throws RSVPParsingException {
final int wrongType = 99;
assertNull(this.simpleXROSubobjectRegistry.parseSubobject(wrongType, this.input, false));
final ByteBuf output = Unpooled.EMPTY_BUFFER;
final SubobjectContainer container = new SubobjectContainerBuilder().setSubobjectType(new LabelCaseBuilder().build()).build();
this.simpleXROSubobjectRegistry.serializeSubobject(container, output);
assertEquals(0, output.readableBytes());
}
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 SimpleRROSubobjectRegistryTest method testUnrecognizedType.
@Test
public void testUnrecognizedType() throws RSVPParsingException {
final int wrongType = 99;
assertNull(this.simpleRROSubobjectRegistry.parseSubobject(wrongType, this.input));
final ByteBuf output = Unpooled.EMPTY_BUFFER;
final SubobjectContainer container = new SubobjectContainerBuilder().setSubobjectType(new LabelCaseBuilder().build()).build();
this.simpleRROSubobjectRegistry.serializeSubobject(container, output);
assertEquals(0, output.readableBytes());
}
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 SimpleRROSubobjectRegistryTest method testSerializerRegistration.
@Test
public void testSerializerRegistration() {
assertNotNull(this.simpleRROSubobjectRegistry.registerSubobjectSerializer(LabelCase.class, this.rroSubobjectSerializer));
final ByteBuf output = Unpooled.buffer();
final SubobjectContainer container = new SubobjectContainerBuilder().setSubobjectType(new LabelCaseBuilder().build()).build();
this.simpleRROSubobjectRegistry.serializeSubobject(container, output);
assertEquals(1, output.readableBytes());
}
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 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("Parsing failed for subobject type: {}. Ignoring subobject.", type);
} else {
LOG.debug("Subobject was parsed. {}", sub);
subs.add(sub);
}
}
return subs;
}
Aggregations