use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message in project bgpcep by opendaylight.
the class Stateful07PCReportMessageParser method serializeMessage.
@Override
public void serializeMessage(final Message message, final ByteBuf out) {
Preconditions.checkArgument(message instanceof Pcrpt, "Wrong instance of Message. Passed instance of %s. Need Pcrpt.", message.getClass());
final Pcrpt msg = (Pcrpt) message;
final List<Reports> reports = msg.getPcrptMessage().getReports();
final ByteBuf buffer = Unpooled.buffer();
for (final Reports report : reports) {
serializeReport(report, buffer);
}
MessageUtil.formatMessage(TYPE, buffer, out);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message in project bgpcep by opendaylight.
the class Stateful07PCReportMessageParser method validateLsp.
private static boolean validateLsp(final Object object, final boolean lspViaSR, final List<Message> errors, final ReportsBuilder builder) {
if (object instanceof Lsp) {
final Lsp lsp = (Lsp) object;
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.Tlvs tlvs = lsp.getTlvs();
if (!lspViaSR && lsp.getPlspId().getValue() != 0 && (tlvs == null || tlvs.getLspIdentifiers() == null)) {
final Message errorMsg = createErrorMsg(PCEPErrors.LSP_IDENTIFIERS_TLV_MISSING, Optional.absent());
errors.add(errorMsg);
return false;
}
builder.setLsp(lsp);
return true;
}
errors.add(createErrorMsg(PCEPErrors.LSP_MISSING, Optional.absent()));
return false;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message in project bgpcep by opendaylight.
the class Stateful07PCReportMessageParser method validatePath.
private static boolean validatePath(final List<Object> objects, final List<Message> errors, final ReportsBuilder builder) {
final PathBuilder pBuilder = new PathBuilder();
Object object = objects.remove(0);
if (object instanceof Ero) {
pBuilder.setEro((Ero) object);
} else {
errors.add(createErrorMsg(PCEPErrors.ERO_MISSING, Optional.absent()));
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.rev131005.Message 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.types.rev131005.Message in project bgpcep by opendaylight.
the class Stateful07PCUpdateRequestMessageParser method serializeMessage.
@Override
public void serializeMessage(final Message message, final ByteBuf out) {
Preconditions.checkArgument(message instanceof Pcupd, "Wrong instance of Message. Passed instance of %s. Need Pcupd.", message.getClass());
final Pcupd msg = (Pcupd) message;
final List<Updates> updates = msg.getPcupdMessage().getUpdates();
final ByteBuf buffer = Unpooled.buffer();
for (final Updates update : updates) {
serializeUpdate(update, buffer);
}
MessageUtil.formatMessage(TYPE, buffer, out);
}
Aggregations