use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject in project bgpcep by opendaylight.
the class AbstractMessageParser method addVendorInformationObjects.
protected static List<VendorInformationObject> addVendorInformationObjects(final List<Object> objects) {
final List<VendorInformationObject> vendorInfo = new ArrayList<>();
while (!objects.isEmpty() && objects.get(0) instanceof VendorInformationObject) {
final VendorInformationObject viObject = (VendorInformationObject) objects.get(0);
vendorInfo.add(viObject);
objects.remove(0);
}
return vendorInfo;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testVendorInformationObject.
@Test
public void testVendorInformationObject() throws PCEPDeserializerException {
final byte[] viObjBytes = { /* vendor-information object */
0x22, 0x10, 0x00, 0x0C, /* enterprise number */
0x00, 0x00, 0x00, 0x00, /* enterprise specific information */
0x00, 0x00, 0x00, 0x05 };
final TestVendorInformationObjectParser parser = new TestVendorInformationObjectParser();
final TestEnterpriseSpecificInformation esInfo = new TestEnterpriseSpecificInformation(5);
final VendorInformationObject viObj = new VendorInformationObjectBuilder().setEnterpriseNumber(new EnterpriseNumber(0L)).setEnterpriseSpecificInformation(esInfo).build();
final ByteBuf result = Unpooled.wrappedBuffer(viObjBytes);
result.readerIndex(8);
final VendorInformationObject o = (VendorInformationObject) parser.parseObject(new ObjectHeaderImpl(false, false), result.readSlice(result.readableBytes()));
assertEquals(viObj, o);
final ByteBuf buf = Unpooled.buffer(viObjBytes.length);
parser.serializeObject(viObj, buf);
assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject in project bgpcep by opendaylight.
the class PCEPReplyMessageParser method handleEro.
private Result handleEro(final Ero ero, final List<Object> objects) {
objects.remove(0);
final SuccessBuilder builder = new SuccessBuilder();
final List<Paths> paths = new ArrayList<>();
final PathsBuilder pBuilder = new PathsBuilder();
pBuilder.setEro(ero);
while (!objects.isEmpty() && !(objects.get(0) instanceof PceId)) {
final List<VendorInformationObject> vendorInfoObjects = addVendorInformationObjects(objects);
if (!vendorInfoObjects.isEmpty()) {
builder.setVendorInformationObject(vendorInfoObjects);
}
this.parsePath(pBuilder, objects);
paths.add(pBuilder.build());
}
builder.setPaths(paths);
return new SuccessCaseBuilder().setSuccess(builder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject in project bgpcep by opendaylight.
the class AbstractVendorInformationObjectParser method serializeObject.
@Override
public final void serializeObject(final Object object, final ByteBuf buffer) {
Preconditions.checkArgument(object instanceof VendorInformationObject, "Wrong instance of PCEPObject. Passed %s. Needed VendorInformationObject.", object.getClass());
final ByteBuf body = Unpooled.buffer();
writeUnsignedInt(getEnterpriseNumber().getValue(), body);
serializeEnterpriseSpecificInformation(((VendorInformationObject) object).getEnterpriseSpecificInformation(), body);
ObjectUtil.formatSubobject(VENDOR_INFORMATION_OBJECT_TYPE, VENDOR_INFORMATION_OBJECT_CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
Aggregations