use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.Errors in project bgpcep by opendaylight.
the class StatefulPCRequestMessageParser method insertP2PObject.
// Note: objects is expected to be non-empty and caller will remove the first object if non-empty
@SuppressWarnings("fallthrough")
private static P2PState insertP2PObject(final P2PState p2PState, final Queue<Object> objects, final List<VendorInformationObject> viObjects, final P2pBuilder builder, final List<Metrics> metrics, final List<Message> errors, final Rp rp) {
final Object obj = objects.element();
switch(p2PState) {
case INIT:
if (obj instanceof Rro) {
builder.setRro((Rro) obj);
objects.remove();
// FIXME: should we guard against empty objects?
final Object nextObj = objects.element();
if (nextObj instanceof ReoptimizationBandwidth) {
builder.setReoptimizationBandwidth((ReoptimizationBandwidth) nextObj);
}
return P2PState.REPORTED_IN;
}
// fallthrough
case REPORTED_IN:
if (obj instanceof VendorInformationObject) {
viObjects.add((VendorInformationObject) obj);
return P2PState.REPORTED_IN;
}
// fallthrough
case VENDOR_INFO_LIST:
if (obj instanceof LoadBalancing) {
builder.setLoadBalancing((LoadBalancing) obj);
return P2PState.LOAD_BIN;
}
// fallthrough
case LOAD_BIN:
if (obj instanceof Lsp) {
builder.addAugmentation(new P2p1Builder().setLsp((Lsp) obj).build());
return P2PState.LSP_IN;
}
// fallthrough
case LSP_IN:
if (obj instanceof Lspa) {
builder.setLspa((Lspa) obj);
return P2PState.LSPA_IN;
}
// fallthrough
case LSPA_IN:
if (obj instanceof Bandwidth) {
builder.setBandwidth((Bandwidth) obj);
return P2PState.BANDWIDTH_IN;
}
// fallthrough
case BANDWIDTH_IN:
if (obj instanceof Metric) {
metrics.add(new MetricsBuilder().setMetric((Metric) obj).build());
return P2PState.BANDWIDTH_IN;
}
// fallthrough
case METRIC_IN:
if (obj instanceof Iro) {
builder.setIro((Iro) obj);
return P2PState.IRO_IN;
}
// fallthrough
case IRO_IN:
if (obj instanceof Rro) {
builder.setRro((Rro) obj);
return P2PState.RRO_IN;
}
// fallthrough
case RRO_IN:
if (obj instanceof Xro) {
builder.setXro((Xro) obj);
return P2PState.XRO_IN;
}
// fallthrough
case XRO_IN:
if (obj instanceof Of) {
builder.setOf((Of) obj);
return P2PState.OF_IN;
}
// fallthrough
case OF_IN:
if (obj instanceof ClassType) {
final ClassType classType = (ClassType) obj;
if (!classType.getProcessingRule()) {
errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.of(rp)));
} else {
builder.setClassType(classType);
}
return P2PState.CT_IN;
}
// fallthrough
case CT_IN:
case END:
return P2PState.END;
default:
return p2PState;
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.Errors 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.types.rev181109.pcerr.message.pcerr.message.Errors in project bgpcep by opendaylight.
the class StatefulPCReportMessageParser method validatePath.
private static boolean validatePath(final Queue<Object> objects, final List<Message> errors, final ReportsBuilder builder) {
final PathBuilder pBuilder = new PathBuilder();
Object object = objects.remove();
if (object instanceof Ero) {
pBuilder.setEro((Ero) object);
} else {
errors.add(createErrorMsg(PCEPErrors.ERO_MISSING, Optional.empty()));
return false;
}
parsePath(objects, pBuilder);
builder.setPath(pBuilder.build());
return true;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.Errors in project bgpcep by opendaylight.
the class FiniteStateMachineTest method testTLSUnexpectedMessage.
/**
* As PCE does not receive expected message (StartTLS), error PCEPErrors.NON_STARTTLS_MSG_RCVD is send.
*/
@Test
public void testTLSUnexpectedMessage() {
this.tlsSessionNegotiator.channelActive(null);
assertEquals(1, this.msgsSend.size());
assertTrue(this.msgsSend.get(0) instanceof Starttls);
assertEquals(DefaultPCEPSessionNegotiator.State.START_TLS_WAIT, this.tlsSessionNegotiator.getState());
this.tlsSessionNegotiator.handleMessage(this.openMsg);
assertEquals(2, this.msgsSend.size());
assertTrue(this.msgsSend.get(1) instanceof Pcerr);
final Errors obj = ((Pcerr) this.msgsSend.get(1)).getPcerrMessage().getErrors().get(0);
assertEquals(PCEPErrors.NON_STARTTLS_MSG_RCVD.getErrorType(), obj.getErrorObject().getType());
assertEquals(PCEPErrors.NON_STARTTLS_MSG_RCVD.getErrorValue(), obj.getErrorObject().getValue());
assertEquals(this.tlsSessionNegotiator.getState(), DefaultPCEPSessionNegotiator.State.FINISHED);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.Errors in project bgpcep by opendaylight.
the class FiniteStateMachineTest method testFailedToEstablishTLS.
/**
* As Tls is not configured properly, PCE will send error PCEPErrors.NOT_POSSIBLE_WITHOUT_TLS.
*/
@Test
public void testFailedToEstablishTLS() {
this.tlsSessionNegotiator.channelActive(null);
assertEquals(1, this.msgsSend.size());
assertTrue(this.msgsSend.get(0) instanceof Starttls);
assertEquals(DefaultPCEPSessionNegotiator.State.START_TLS_WAIT, this.tlsSessionNegotiator.getState());
this.tlsSessionNegotiator.handleMessage(this.startTlsMsg);
assertEquals(2, this.msgsSend.size());
assertTrue(this.msgsSend.get(1) instanceof Pcerr);
final Errors obj = ((Pcerr) this.msgsSend.get(1)).getPcerrMessage().getErrors().get(0);
assertEquals(PCEPErrors.NOT_POSSIBLE_WITHOUT_TLS.getErrorType(), obj.getErrorObject().getType());
assertEquals(PCEPErrors.NOT_POSSIBLE_WITHOUT_TLS.getErrorValue(), obj.getErrorObject().getValue());
assertEquals(DefaultPCEPSessionNegotiator.State.FINISHED, this.tlsSessionNegotiator.getState());
}
Aggregations