use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ClassType in project bgpcep by opendaylight.
the class Stateful07RSVPErrorSpecTlvParser method parseTlv.
@Override
public RsvpErrorSpec parseTlv(final ByteBuf buffer) throws PCEPDeserializerException {
if (buffer == null) {
return null;
}
// throw away contents of length field
buffer.readUnsignedShort();
final int classNum = buffer.readUnsignedByte();
final int classType = buffer.readUnsignedByte();
ErrorType errorType = null;
if (classNum == RSVP_ERROR_CLASS_NUM) {
errorType = parseRsvp(classType, buffer.slice());
} else if (classNum == USER_ERROR_CLASS_NUM && classType == USER_ERROR_CLASS_TYPE) {
errorType = parseUserError(buffer.slice());
}
return new RsvpErrorSpecBuilder().setErrorType(errorType).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ClassType 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.rev181109.ClassType in project bgpcep by opendaylight.
the class PCEPClassTypeObjectParser method parseObject.
@Override
public Object parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
if (!header.getProcessingRule()) {
LOG.debug("Processed bit not set on CLASS TYPE OBJECT, ignoring it");
return null;
}
if (bytes.readableBytes() != SIZE) {
throw new PCEPDeserializerException("Size of byte array doesn't match defined size. Expected: " + SIZE + "; Passed: " + bytes.readableBytes());
}
final short ct = (short) bytes.readUnsignedInt();
final ClassTypeBuilder builder = new ClassTypeBuilder().setIgnore(header.getIgnore()).setProcessingRule(header.getProcessingRule()).setClassType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ClassType(Uint8.valueOf(ct)));
if (ct < 0 || ct > Byte.SIZE) {
LOG.debug("Invalid class type {}", ct);
return new UnknownObject(PCEPErrors.INVALID_CT, builder.build());
}
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ClassType 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.ClassType in project bgpcep by opendaylight.
the class StatefulRSVPErrorSpecTlvParser method parseRsvp.
private static RsvpCase parseRsvp(final int classType, final ByteBuf buffer) {
final RsvpErrorBuilder builder = new RsvpErrorBuilder();
if (classType == RSVP_IPV4_ERROR_CLASS_TYPE) {
builder.setNode(new IpAddressNoZone(Ipv4Util.addressForByteBuf(buffer)));
} else if (classType == RSVP_IPV6_ERROR_CLASS_TYPE) {
builder.setNode(new IpAddressNoZone(Ipv6Util.addressForByteBuf(buffer)));
}
final BitArray flags = BitArray.valueOf(buffer, FLAGS_SIZE);
builder.setFlags(new Flags(flags.get(IN_PLACE), flags.get(NOT_GUILTY)));
builder.setCode(ByteBufUtils.readUint8(buffer));
builder.setValue(ByteBufUtils.readUint16(buffer));
return new RsvpCaseBuilder().setRsvpError(builder.build()).build();
}
Aggregations