use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.Rro in project bgpcep by opendaylight.
the class PCEPRequestMessageParser method insertObject.
private static State insertObject(final State state, final List<Object> objects, final List<VendorInformationObject> viObjects, final P2pBuilder builder, final List<Metrics> metrics, final List<Message> errors, final Rp rp) {
final Object obj = objects.get(0);
switch(state) {
case INIT:
if (obj instanceof Rro) {
builder.setRro((Rro) obj);
objects.remove(0);
final Object nextObj = objects.get(0);
if (nextObj instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reoptimization.bandwidth.object.ReoptimizationBandwidth) {
builder.setReoptimizationBandwidth((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reoptimization.bandwidth.object.ReoptimizationBandwidth) nextObj);
}
return State.REPORTED_IN;
}
case REPORTED_IN:
if (obj instanceof VendorInformationObject) {
viObjects.add((VendorInformationObject) obj);
return State.REPORTED_IN;
}
case VENDOR_INFO_LIST:
if (obj instanceof LoadBalancing) {
builder.setLoadBalancing((LoadBalancing) obj);
return State.LOAD_BIN;
}
case LOAD_BIN:
if (obj instanceof Lspa) {
builder.setLspa((Lspa) obj);
return State.LSPA_IN;
}
case LSPA_IN:
if (obj instanceof Bandwidth) {
builder.setBandwidth((Bandwidth) obj);
return State.BANDWIDTH_IN;
}
case BANDWIDTH_IN:
if (obj instanceof Metric) {
metrics.add(new MetricsBuilder().setMetric((Metric) obj).build());
return State.BANDWIDTH_IN;
}
case METRIC_IN:
if (obj instanceof Iro) {
builder.setIro((Iro) obj);
return State.IRO_IN;
}
case IRO_IN:
if (obj instanceof Rro) {
builder.setRro((Rro) obj);
return State.RRO_IN;
}
case RRO_IN:
if (obj instanceof Xro) {
builder.setXro((Xro) obj);
return State.XRO_IN;
}
case XRO_IN:
if (obj instanceof Of) {
builder.setOf((Of) obj);
return State.OF_IN;
}
case OF_IN:
if (obj instanceof ClassType) {
final ClassType classType = (ClassType) obj;
if (!classType.isProcessingRule()) {
errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.of(rp)));
} else {
builder.setClassType(classType);
}
return State.CT_IN;
}
case CT_IN:
case END:
return State.END;
default:
return state;
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.Rro in project bgpcep by opendaylight.
the class PCEPReportedRouteObjectParser method serializeObject.
@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
Preconditions.checkArgument(object instanceof Rro, "Wrong instance of PCEPObject. Passed %s. Needed RroObject.", object.getClass());
final Rro obj = (Rro) object;
final ByteBuf body = Unpooled.buffer();
serializeSubobject(obj.getSubobject(), body);
ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.Rro in project bgpcep by opendaylight.
the class TeLspAttributesParser method serializeLspAttributes.
static void serializeLspAttributes(final RSVPTeObjectRegistry registry, final TeLspAttributesCase linkState, final ByteBuf output) {
LOG.trace("Started serializing TE LSP Objects");
final ByteBuf byteBuf = Unpooled.buffer();
final TeLspAttributes teLspAttribute = linkState.getTeLspAttributes();
final TspecObject tSpec = teLspAttribute.getTspecObject();
registry.serializeRSPVTe(tSpec, byteBuf);
final FlowSpecObject flow = teLspAttribute.getFlowSpecObject();
registry.serializeRSPVTe(flow, byteBuf);
final SessionAttributeObject sao = teLspAttribute.getSessionAttributeObject();
if (sao instanceof BasicSessionAttributeObject) {
registry.serializeRSPVTe((BasicSessionAttributeObject) sao, byteBuf);
} else if (sao instanceof SessionAttributeObjectWithResourcesAffinities) {
registry.serializeRSPVTe((SessionAttributeObjectWithResourcesAffinities) sao, byteBuf);
}
final ExplicitRouteObject ero = teLspAttribute.getExplicitRouteObject();
registry.serializeRSPVTe(ero, byteBuf);
final RecordRouteObject rro = teLspAttribute.getRecordRouteObject();
registry.serializeRSPVTe(rro, byteBuf);
final FastRerouteObject fro = teLspAttribute.getFastRerouteObject();
if (fro instanceof BasicFastRerouteObject) {
registry.serializeRSPVTe((BasicFastRerouteObject) fro, byteBuf);
} else if (fro instanceof LegacyFastRerouteObject) {
registry.serializeRSPVTe((LegacyFastRerouteObject) fro, byteBuf);
}
final DetourObject dto = teLspAttribute.getDetourObject();
if (dto instanceof Ipv4DetourObject) {
registry.serializeRSPVTe((Ipv4DetourObject) dto, byteBuf);
} else if (dto instanceof Ipv6DetourObject) {
registry.serializeRSPVTe((Ipv6DetourObject) dto, byteBuf);
}
final ExcludeRouteObject exro = teLspAttribute.getExcludeRouteObject();
registry.serializeRSPVTe(exro, byteBuf);
final SecondaryExplicitRouteObject sero = teLspAttribute.getSecondaryExplicitRouteObject();
registry.serializeRSPVTe(sero, byteBuf);
final SecondaryRecordRouteObject srro = teLspAttribute.getSecondaryRecordRouteObject();
registry.serializeRSPVTe(srro, byteBuf);
final LspAttributesObject lspAtt = teLspAttribute.getLspAttributesObject();
registry.serializeRSPVTe(lspAtt, byteBuf);
final LspRequiredAttributesObject rao = teLspAttribute.getLspRequiredAttributesObject();
registry.serializeRSPVTe(rao, byteBuf);
final ProtectionObject po = teLspAttribute.getProtectionObject();
if (po instanceof DynamicControlProtectionObject) {
registry.serializeRSPVTe((DynamicControlProtectionObject) po, byteBuf);
} else if (po instanceof BasicProtectionObject) {
registry.serializeRSPVTe((BasicProtectionObject) po, byteBuf);
}
final AssociationObject aso = teLspAttribute.getAssociationObject();
registry.serializeRSPVTe(aso, byteBuf);
final PrimaryPathRouteObject ppr = teLspAttribute.getPrimaryPathRouteObject();
registry.serializeRSPVTe(ppr, byteBuf);
final AdminStatusObject adso = teLspAttribute.getAdminStatusObject();
registry.serializeRSPVTe(adso, byteBuf);
final BandwidthObject bo = teLspAttribute.getBandwidthObject();
if (bo instanceof BasicBandwidthObject) {
registry.serializeRSPVTe((BasicBandwidthObject) bo, byteBuf);
} else if (bo instanceof ReoptimizationBandwidthObject) {
registry.serializeRSPVTe((ReoptimizationBandwidthObject) bo, byteBuf);
}
final MetricObject mo = teLspAttribute.getMetricObject();
registry.serializeRSPVTe(mo, byteBuf);
output.writeShort(MAGIC_NUMBER);
output.writeShort(byteBuf.readableBytes());
output.writeBytes(byteBuf);
LOG.trace("Finished serializing TE LSP Objects");
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.Rro in project bgpcep by opendaylight.
the class PCEPValidatorTest method testUnexpectedRroObjectInPcUpdMsg.
@Test
public void testUnexpectedRroObjectInPcUpdMsg() throws PCEPDeserializerException {
final byte[] badUpdateMsg = { (byte) 0x20, (byte) 0x0b, (byte) 0x00, (byte) 0x50, /* SRP, LSP and ERO objects */
(byte) 0x21, (byte) 0x12, (byte) 0x00, (byte) 0x0c, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x20, (byte) 0x10, (byte) 0x00, (byte) 0x08, (byte) 0x00, (byte) 0x00, (byte) 0x10, (byte) 0x09, (byte) 0x07, (byte) 0x10, (byte) 0x00, (byte) 0x14, (byte) 0x01, (byte) 0x08, (byte) 0x05, (byte) 0x05, (byte) 0x05, (byte) 0x03, (byte) 0x18, (byte) 0x00, (byte) 0x01, (byte) 0x08, (byte) 0x08, (byte) 0x08, (byte) 0x08, (byte) 0x04, (byte) 0x18, (byte) 0x00, /* RRO object */
(byte) 0x08, (byte) 0x10, (byte) 0x00, (byte) 0x24, (byte) 0x01, (byte) 0x08, (byte) 0x0a, (byte) 0x00, (byte) 0x00, (byte) 0x83, (byte) 0x20, (byte) 0x20, (byte) 0x03, (byte) 0x08, (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x08, (byte) 0x0a, (byte) 0x00, (byte) 0x09, (byte) 0xde, (byte) 0x20, (byte) 0x00, (byte) 0x03, (byte) 0x08, (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
try (CrabbeInitiatedActivator a = new CrabbeInitiatedActivator()) {
a.start(this.ctx);
final Stateful07PCUpdateRequestMessageParser parser = new Stateful07PCUpdateRequestMessageParser(this.ctx.getObjectHandlerRegistry());
final PcerrMessageBuilder errMsgBuilder = new PcerrMessageBuilder();
errMsgBuilder.setErrors(Lists.newArrayList(new ErrorsBuilder().setErrorObject(new ErrorObjectBuilder().setType((short) 6).setValue((short) 10).build()).build()));
final PcerrBuilder builder = new PcerrBuilder();
builder.setPcerrMessage(errMsgBuilder.build());
final ByteBuf buf = Unpooled.wrappedBuffer(badUpdateMsg);
final List<Message> errors = Lists.newArrayList();
parser.parseMessage(buf.slice(4, buf.readableBytes() - 4), errors);
assertFalse(errors.isEmpty());
assertEquals(builder.build(), errors.get(0));
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.Rro in project bgpcep by opendaylight.
the class PCEPReportedRouteObjectParser method parseObject.
@Override
public Rro parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
final RroBuilder builder = new RroBuilder();
builder.setIgnore(header.isIgnore());
builder.setProcessingRule(header.isProcessingRule());
builder.setSubobject(parseSubobjects(bytes.slice()));
return builder.build();
}
Aggregations