use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.srp.object.Srp 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 };
new InitiatedActivator().start(ctx);
final StatefulPCUpdateRequestMessageParser parser = new StatefulPCUpdateRequestMessageParser(this.ctx.getObjectHandlerRegistry());
final ByteBuf buf = Unpooled.wrappedBuffer(badUpdateMsg);
final List<Message> errors = new ArrayList<>();
parser.parseMessage(buf.slice(4, buf.readableBytes() - 4), errors);
assertFalse(errors.isEmpty());
assertEquals(new PcerrBuilder().setPcerrMessage(new PcerrMessageBuilder().setErrors(List.of(new ErrorsBuilder().setErrorObject(new ErrorObjectBuilder().setType(Uint8.valueOf(6)).setValue(Uint8.valueOf(10)).build()).build())).build()).build(), errors.get(0));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.srp.object.Srp in project bgpcep by opendaylight.
the class StatefulSrpObjectParser method serializeObject.
@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
checkArgument(object instanceof Srp, "Wrong instance of PCEPObject. Passed %s . Needed SrpObject.", object.getClass());
final Srp srp = (Srp) object;
final ByteBuf body = Unpooled.buffer();
serializeFlags(srp, body);
final SrpIdNumber srpId = srp.getOperationId();
checkArgument(srpId != null, "SrpId is mandatory.");
ByteBufUtils.write(body, srpId.getValue());
serializeTlvs(srp.getTlvs(), body);
ObjectUtil.formatSubobject(TYPE, CLASS, object.getProcessingRule(), object.getIgnore(), body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.srp.object.Srp in project bgpcep by opendaylight.
the class StatefulErrorMessageParser method validate.
@Override
protected PcerrMessage validate(final Queue<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
checkArgument(objects != null, "Passed list can't be null.");
final Object first = objects.peek();
if (first == null) {
throw new PCEPDeserializerException("Error message is empty.");
}
final List<Rps> requestParameters = new ArrayList<>();
final List<Srps> srps = new ArrayList<>();
final List<Errors> errorObjects = new ArrayList<>();
final PcerrMessageBuilder b = new PcerrMessageBuilder();
State state = State.INIT;
if (first instanceof ErrorObject) {
errorObjects.add(new ErrorsBuilder().setErrorObject((ErrorObject) first).build());
state = State.ERROR_IN;
} else if (first instanceof Rp) {
final Rp rp = (Rp) first;
if (rp.getProcessingRule()) {
errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.empty()));
return null;
}
requestParameters.add(new RpsBuilder().setRp(rp).build());
state = State.RP_IN;
} else if (first instanceof Srp) {
srps.add(new SrpsBuilder().setSrp((Srp) first).build());
state = State.SRP_IN;
}
if (state != State.INIT) {
objects.remove();
}
for (Object obj = objects.peek(); obj != null; obj = objects.peek()) {
if (obj instanceof UnknownObject) {
return new PcerrBuilder().setPcerrMessage(b.setErrors(((UnknownObject) obj).getErrors()).build()).build();
}
state = insertObject(state, obj, errorObjects, requestParameters, srps, b);
if (state == State.END) {
break;
}
objects.remove();
}
if (errorObjects.isEmpty()) {
throw new PCEPDeserializerException("At least one PCEPErrorObject is mandatory.");
}
if (!objects.isEmpty()) {
throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
}
if (!requestParameters.isEmpty()) {
b.setErrorType(new RequestCaseBuilder().setRequest(new RequestBuilder().setRps(requestParameters).build()).build());
}
if (!srps.isEmpty()) {
b.setErrorType(new StatefulCaseBuilder().setStateful(new StatefulBuilder().setSrps(srps).build()).build());
}
return new PcerrBuilder().setPcerrMessage(b.setErrors(errorObjects).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.srp.object.Srp in project bgpcep by opendaylight.
the class StatefulPCReportMessageParser method getValidReports.
protected Reports getValidReports(final Queue<Object> objects, final List<Message> errors) {
final ReportsBuilder builder = new ReportsBuilder();
boolean lspViaSR = false;
Object object = objects.remove();
if (object instanceof Srp) {
final Srp srp = (Srp) object;
final Tlvs tlvs = srp.getTlvs();
if (tlvs != null) {
lspViaSR = PSTUtil.isDefaultPST(tlvs.getPathSetupType());
}
builder.setSrp(srp);
object = objects.poll();
}
if (validateLsp(object, lspViaSR, errors, builder)) {
if (!objects.isEmpty()) {
if (!validatePath(objects, errors, builder)) {
return null;
}
}
return builder.build();
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.srp.object.Srp in project bgpcep by opendaylight.
the class PCCTunnelManagerImpl method reportToAll.
protected void reportToAll(final Updates update, final PCCSession session) {
final PlspId plspId = update.getLsp().getPlspId();
final PCCTunnel tunnel = this.tunnels.get(plspId);
final Uint32 srpId = update.getSrp().getOperationId().getValue();
if (tunnel != null) {
if (hasDelegation(tunnel, session)) {
final Srp srp = createSrp(srpId);
final Path path = updToRptPath(update.getPath());
final List<Subobject> subobjects = update.getPath().getEro().getSubobject();
final Lsp lsp = update.getLsp();
sendToAll(tunnel, plspId, subobjects, srp, path, lsp);
// update tunnel state
tunnel.setLspState(path);
} else {
session.sendError(MsgBuilderUtil.createErrorMsg(PCEPErrors.UPDATE_REQ_FOR_NON_LSP, srpId));
}
} else {
session.sendError(MsgBuilderUtil.createErrorMsg(PCEPErrors.UNKNOWN_PLSP_ID, srpId));
}
}
Aggregations