use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.srp.object.Srp in project bgpcep by opendaylight.
the class Stateful07TopologySessionListener method createUpdateMessageSync.
private SrpIdNumber createUpdateMessageSync(final PcupdMessageBuilder pcupdMessageBuilder) {
final UpdatesBuilder updBuilder = new UpdatesBuilder();
// LSP mandatory in Upd
final Lsp lsp = new LspBuilder().setPlspId(new PlspId(0L)).setSync(Boolean.TRUE).build();
// SRP Mandatory in Upd
final SrpBuilder srpBuilder = new SrpBuilder();
// not sue whether use 0 instead of nextRequest() or do not insert srp == SRP-ID-number = 0
srpBuilder.setOperationId(nextRequest());
final Srp srp = srpBuilder.build();
// ERO Mandatory in Upd
final PathBuilder pb = new PathBuilder();
pb.setEro(new EroBuilder().build());
updBuilder.setPath(pb.build());
updBuilder.setLsp(lsp).setSrp(srp).setPath(pb.build());
pcupdMessageBuilder.setUpdates(Collections.singletonList(updBuilder.build()));
return srp.getOperationId();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.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 };
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.ietf.stateful.rev171025.srp.object.Srp in project bgpcep by opendaylight.
the class Stateful07ErrorMessageParser method insertObject.
private static State insertObject(final State state, final Object obj, final List<Errors> errorObjects, final List<Rps> requestParameters, final List<Srps> srps, final PcerrMessageBuilder b) {
switch(state) {
case ERROR_IN:
if (obj instanceof ErrorObject) {
final ErrorObject o = (ErrorObject) obj;
errorObjects.add(new ErrorsBuilder().setErrorObject(o).build());
return State.ERROR_IN;
}
case RP_IN:
if (obj instanceof Rp) {
final Rp o = (Rp) obj;
requestParameters.add(new RpsBuilder().setRp(o).build());
return State.RP_IN;
}
case SRP_IN:
if (obj instanceof Srp) {
final Srp o = (Srp) obj;
srps.add(new SrpsBuilder().setSrp(o).build());
return State.SRP_IN;
}
case OPEN:
if (obj instanceof Open) {
b.setErrorType(new SessionCaseBuilder().setSession(new SessionBuilder().setOpen((Open) obj).build()).build());
return State.OPEN_IN;
}
case ERROR:
if (obj instanceof ErrorObject) {
final ErrorObject o = (ErrorObject) obj;
errorObjects.add(new ErrorsBuilder().setErrorObject(o).build());
return State.ERROR;
}
case OPEN_IN:
case END:
return State.END;
default:
return state;
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.srp.object.Srp in project bgpcep by opendaylight.
the class Stateful07PCUpdateRequestMessageParser method getValidUpdates.
protected Updates getValidUpdates(final List<Object> objects, final List<Message> errors) {
final UpdatesBuilder builder = new UpdatesBuilder();
Object object = objects.remove(0);
if (object instanceof Srp) {
builder.setSrp((Srp) object);
if (objects.isEmpty()) {
object = null;
} else {
object = objects.remove(0);
}
} else {
errors.add(createErrorMsg(PCEPErrors.SRP_MISSING, Optional.absent()));
}
if (validateLsp(object, 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.rev171025.srp.object.Srp in project bgpcep by opendaylight.
the class Stateful07SrpObjectParser method serializeObject.
@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
Preconditions.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();
Preconditions.checkArgument(srpId != null, "SrpId is mandatory.");
writeUnsignedInt(srpId.getValue(), body);
serializeTlvs(srp.getTlvs(), body);
ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
Aggregations