use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject in project bgpcep by opendaylight.
the class PCEPRequestMessageParser method getValidSvec.
// Note: objects is expected to be non-empty
private static Svec getValidSvec(final SvecBuilder builder, final Queue<Object> objects) {
final Object svec = objects.element();
if (svec instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.svec.object.Svec) {
builder.setSvec((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.svec.object.Svec) svec);
objects.remove();
} else {
return null;
}
// FIXME: this list is not retained anywhere
final List<Metrics> metrics = new ArrayList<>();
final List<VendorInformationObject> viObjects = new ArrayList<>();
SvecState state = SvecState.INIT;
for (Object obj = objects.peek(); obj != null; obj = objects.peek()) {
state = insertP2PObject(state, obj, builder, metrics, viObjects);
if (state == SvecState.END) {
break;
}
objects.remove();
}
if (!viObjects.isEmpty()) {
builder.setVendorInformationObject(viObjects);
}
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject in project bgpcep by opendaylight.
the class PCEPReplyMessageParser method handleEros.
private Result handleEros(final Queue<Object> objects) {
final SuccessBuilder builder = new SuccessBuilder();
final List<Paths> paths = new ArrayList<>();
for (Object obj = objects.peek(); obj != null && !(obj instanceof PceId); obj = objects.peek()) {
final PathsBuilder pBuilder = new PathsBuilder();
if (obj instanceof Ero) {
pBuilder.setEro((Ero) obj);
objects.remove();
}
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.rev181109.vendor.information.objects.VendorInformationObject in project bgpcep by opendaylight.
the class PCEPReplyMessageParser method getValidReply.
protected Replies getValidReply(final Queue<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
Object obj = objects.remove();
if (!(obj instanceof Rp)) {
errors.add(createErrorMsg(PCEPErrors.RP_MISSING, Optional.empty()));
return null;
}
final RepliesBuilder repliesBuilder = new RepliesBuilder().setRp((Rp) obj);
obj = objects.peek();
if (obj instanceof Monitoring) {
repliesBuilder.setMonitoring((Monitoring) obj);
objects.remove();
obj = objects.peek();
}
if (obj instanceof PccIdReq) {
repliesBuilder.setPccIdReq((PccIdReq) obj);
objects.remove();
// last option, no need to peek
}
// note: this may modify 'objects'
final List<VendorInformationObject> vendorInfo = addVendorInformationObjects(objects);
if (!vendorInfo.isEmpty()) {
repliesBuilder.setVendorInformationObject(vendorInfo);
}
final Result res;
obj = objects.peek();
if (obj instanceof NoPath) {
objects.remove();
res = handleNoPath((NoPath) obj, objects);
} else if (obj instanceof Ero) {
res = handleEros(objects);
} else {
res = null;
}
if (objects.peek() instanceof PceId) {
final List<MetricPce> metricPceList = new ArrayList<>();
while (!objects.isEmpty()) {
metricPceList.add(Util.validateMonitoringMetrics(objects));
}
if (!metricPceList.isEmpty()) {
repliesBuilder.setMetricPce(metricPceList);
}
}
return repliesBuilder.setResult(res).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.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) {
checkArgument(object instanceof VendorInformationObject, "Wrong instance of PCEPObject. Passed %s. Needed VendorInformationObject.", object.getClass());
final ByteBuf body = Unpooled.buffer();
ByteBufUtils.write(body, getEnterpriseNumber().getValue());
serializeEnterpriseSpecificInformation(((VendorInformationObject) object).getEnterpriseSpecificInformation(), body);
ObjectUtil.formatSubobject(VENDOR_INFORMATION_OBJECT_TYPE, VENDOR_INFORMATION_OBJECT_CLASS, object.getProcessingRule(), object.getIgnore(), body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.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(Uint32.ZERO)).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));
}
Aggregations