use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.reported.route.object.Srro in project bgpcep by opendaylight.
the class TeLspAttributesParser method serializeLspAttributes.
static void serializeLspAttributes(final RSVPTeObjectRegistry registry, final TeLspAttributesCase linkState, final ByteBuf output) {
LOG.trace("Started serializing TE LSP Objects");
final ByteBuf byteBuf = Unpooled.buffer();
final TeLspAttributes teLspAttribute = linkState.getTeLspAttributes();
final TspecObject tSpec = teLspAttribute.getTspecObject();
registry.serializeRSPVTe(tSpec, byteBuf);
final FlowSpecObject flow = teLspAttribute.getFlowSpecObject();
registry.serializeRSPVTe(flow, byteBuf);
final SessionAttributeObject sao = teLspAttribute.getSessionAttributeObject();
if (sao instanceof BasicSessionAttributeObject) {
registry.serializeRSPVTe((BasicSessionAttributeObject) sao, byteBuf);
} else if (sao instanceof SessionAttributeObjectWithResourcesAffinities) {
registry.serializeRSPVTe((SessionAttributeObjectWithResourcesAffinities) sao, byteBuf);
}
final ExplicitRouteObject ero = teLspAttribute.getExplicitRouteObject();
registry.serializeRSPVTe(ero, byteBuf);
final RecordRouteObject rro = teLspAttribute.getRecordRouteObject();
registry.serializeRSPVTe(rro, byteBuf);
final FastRerouteObject fro = teLspAttribute.getFastRerouteObject();
if (fro instanceof BasicFastRerouteObject) {
registry.serializeRSPVTe((BasicFastRerouteObject) fro, byteBuf);
} else if (fro instanceof LegacyFastRerouteObject) {
registry.serializeRSPVTe((LegacyFastRerouteObject) fro, byteBuf);
}
final DetourObject dto = teLspAttribute.getDetourObject();
if (dto instanceof Ipv4DetourObject) {
registry.serializeRSPVTe((Ipv4DetourObject) dto, byteBuf);
} else if (dto instanceof Ipv6DetourObject) {
registry.serializeRSPVTe((Ipv6DetourObject) dto, byteBuf);
}
final ExcludeRouteObject exro = teLspAttribute.getExcludeRouteObject();
registry.serializeRSPVTe(exro, byteBuf);
final SecondaryExplicitRouteObject sero = teLspAttribute.getSecondaryExplicitRouteObject();
registry.serializeRSPVTe(sero, byteBuf);
final SecondaryRecordRouteObject srro = teLspAttribute.getSecondaryRecordRouteObject();
registry.serializeRSPVTe(srro, byteBuf);
final LspAttributesObject lspAtt = teLspAttribute.getLspAttributesObject();
registry.serializeRSPVTe(lspAtt, byteBuf);
final LspRequiredAttributesObject rao = teLspAttribute.getLspRequiredAttributesObject();
registry.serializeRSPVTe(rao, byteBuf);
final ProtectionObject po = teLspAttribute.getProtectionObject();
if (po instanceof DynamicControlProtectionObject) {
registry.serializeRSPVTe((DynamicControlProtectionObject) po, byteBuf);
} else if (po instanceof BasicProtectionObject) {
registry.serializeRSPVTe((BasicProtectionObject) po, byteBuf);
}
final AssociationObject aso = teLspAttribute.getAssociationObject();
registry.serializeRSPVTe(aso, byteBuf);
final PrimaryPathRouteObject ppr = teLspAttribute.getPrimaryPathRouteObject();
registry.serializeRSPVTe(ppr, byteBuf);
final AdminStatusObject adso = teLspAttribute.getAdminStatusObject();
registry.serializeRSPVTe(adso, byteBuf);
final BandwidthObject bo = teLspAttribute.getBandwidthObject();
if (bo instanceof BasicBandwidthObject) {
registry.serializeRSPVTe((BasicBandwidthObject) bo, byteBuf);
} else if (bo instanceof ReoptimizationBandwidthObject) {
registry.serializeRSPVTe((ReoptimizationBandwidthObject) bo, byteBuf);
}
final MetricObject mo = teLspAttribute.getMetricObject();
registry.serializeRSPVTe(mo, byteBuf);
output.writeShort(MAGIC_NUMBER);
output.writeShort(byteBuf.readableBytes());
output.writeBytes(byteBuf);
LOG.trace("Finished serializing TE LSP Objects");
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.reported.route.object.Srro in project bgpcep by opendaylight.
the class PCEPSecondaryRecordRouteObjectParser method parseObject.
@Override
public Srro parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
Preconditions.checkArgument(buffer != null && buffer.isReadable(), EMPTY_ARRAY_ERROR);
final SrroBuilder builder = new SrroBuilder();
builder.setIgnore(header.getIgnore());
builder.setProcessingRule(header.getProcessingRule());
final List<Subobject> subObjects = parseSubobjects(buffer);
builder.setSubobject(subObjects.stream().map(so -> new SubobjectBuilder().setSubobjectType(so.getSubobjectType()).setProtectionAvailable(so.getProtectionAvailable()).setProtectionInUse(so.getProtectionInUse()).build()).collect(Collectors.toList()));
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.reported.route.object.Srro in project bgpcep by opendaylight.
the class SecondaryRecordRouteObjectParser method localParseObject.
@Override
protected RsvpTeObject localParseObject(final ByteBuf byteBuf) throws RSVPParsingException {
final SecondaryRecordRouteObjectBuilder srro = new SecondaryRecordRouteObjectBuilder();
final List<SubobjectContainer> sbo = parseList(byteBuf);
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary._record.route.object.secondary._record.route.object.SubobjectContainer> srroSbo = sbo.stream().map(so -> new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary._record.route.object.secondary._record.route.object.SubobjectContainerBuilder().setProtectionAvailable(so.getProtectionAvailable()).setProtectionInUse(so.getProtectionInUse()).setSubobjectType(so.getSubobjectType()).build()).collect(Collectors.toList());
return srro.setSubobjectContainer(srroSbo).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.reported.route.object.Srro in project bgpcep by opendaylight.
the class PCEPRequestMessageParser method insertP2MPObject.
private static P2MPState insertP2MPObject(final P2MPState p2MPState, final Queue<Object> objects, final P2mpBuilder builder, final List<EndpointRroPair> epRros, final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.p2mp.Metric> metrics, final List<Message> errors, final Rp rp) {
final Object obj = objects.element();
switch(p2MPState) {
case RP:
if (obj instanceof EndpointsObj) {
final EndpointRroPairBuilder rroPairBuilder = new EndpointRroPairBuilder();
if (obj.getProcessingRule()) {
rroPairBuilder.setEndpointsObj((EndpointsObj) obj);
} else {
errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.of(rp)));
}
epRros.add(rroPairBuilder.setRros(new ArrayList<>()).build());
return P2MPState.ENDPOINT;
}
// fallthrough
case ENDPOINT:
if (obj instanceof Rro || obj instanceof Srro) {
if (obj.getProcessingRule()) {
final int lastIndex = epRros.size() - 1;
final EndpointRroPair endpointRroPair = epRros.get(lastIndex);
List<Rros> rros = endpointRroPair.getRros();
if (rros == null) {
rros = new ArrayList<>();
}
if (obj instanceof Rro) {
rros.add(new RrosBuilder().setRouteObject(new ReportedRouteObjectCaseBuilder().setRro((Rro) obj).build()).build());
} else {
rros.add(new RrosBuilder().setRouteObject(new SecondaryReportedRouteObjectCaseBuilder().setSrro((Srro) obj).build()).build());
}
epRros.remove(lastIndex);
epRros.add(lastIndex, new EndpointRroPairBuilder(endpointRroPair).setRros(rros).build());
}
return P2MPState.ENDPOINT;
}
// fallthrough
case RRO_SRRO:
if (obj instanceof ReoptimizationBandwidth) {
final int lastIndex = epRros.size() - 1;
final EndpointRroPair endpointRroPair = epRros.get(lastIndex);
epRros.remove(lastIndex);
epRros.add(lastIndex, new EndpointRroPairBuilder(endpointRroPair).setReoptimizationBandwidth((ReoptimizationBandwidth) obj).build());
return P2MPState.BANDWIDTH;
}
// fallthrough
case BANDWIDTH:
if (obj instanceof EndpointsObj) {
return P2MPState.RP;
}
if (obj instanceof Of) {
builder.setOf((Of) obj);
return P2MPState.OF_IN;
}
// fallthrough
case OF_IN:
if (obj instanceof Lspa) {
builder.setLspa((Lspa) obj);
return P2MPState.LSPA_IN;
}
// fallthrough
case LSPA_IN:
if (obj instanceof Bandwidth) {
builder.setBandwidth((Bandwidth) obj);
return P2MPState.BANDWIDTH_IN;
}
// fallthrough
case BANDWIDTH_IN:
if (obj instanceof Metric) {
metrics.add(new MetricBuilder().setMetric((Metric) obj).build());
return P2MPState.BANDWIDTH_IN;
}
// fallthrough
case METRIC_IN:
if (obj instanceof Iro) {
builder.setIroBncChoice(new IroCaseBuilder().setIro((Iro) obj).build());
return P2MPState.IRO_BNC_IN;
}
if (obj instanceof BranchNodeList) {
builder.setIroBncChoice(new BncCaseBuilder().setBranchNodeType(new BranchNodeCaseBuilder().setBranchNodeList((BranchNodeList) obj).build()).build());
return P2MPState.IRO_BNC_IN;
}
if (obj instanceof NonBranchNodeList) {
builder.setIroBncChoice(new BncCaseBuilder().setBranchNodeType(new NonBranchNodeCaseBuilder().setNonBranchNodeList((NonBranchNodeList) obj).build()).build());
return P2MPState.IRO_BNC_IN;
}
// fallthrough
case IRO_BNC_IN:
if (obj instanceof LoadBalancing) {
builder.setLoadBalancing((LoadBalancing) obj);
return P2MPState.LOAD_BIN;
}
// fallthrough
case LOAD_BIN:
case END:
default:
return P2MPState.END;
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.reported.route.object.Srro in project bgpcep by opendaylight.
the class PCEPSecondaryRecordRouteObjectParser method serializeObject.
@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
Preconditions.checkArgument(object instanceof Srro, "Wrong instance of PCEPObject. Passed %s. Needed EroObject.", object.getClass());
final Srro sero = (Srro) object;
final ByteBuf body = Unpooled.buffer();
final List<Subobject> subObjects = sero.nonnullSubobject().stream().map(so -> new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.rro.SubobjectBuilder().setSubobjectType(so.getSubobjectType()).setProtectionAvailable(so.getProtectionAvailable()).setProtectionInUse(so.getProtectionInUse()).build()).collect(Collectors.toList());
serializeSubobject(subObjects, body);
ObjectUtil.formatSubobject(TYPE, CLASS, object.getProcessingRule(), object.getIgnore(), body, buffer);
}
Aggregations