while (nlri.isReadable()) {
final FlowspecBuilder builder = new FlowspecBuilder();
- // read type
final ComponentType type = ComponentType.forValue(nlri.readUnsignedByte());
builder.setComponentType(type);
- switch (type) {
- case DestinationPrefix:
- builder.setFlowspecType(new DestinationPrefixCaseBuilder().setDestinationPrefix(Ipv4Util.prefixForByteBuf(nlri)).build());
- break;
- case SourcePrefix:
- builder.setFlowspecType(new SourcePrefixCaseBuilder().setSourcePrefix(Ipv4Util.prefixForByteBuf(nlri)).build());
- break;
- case ProtocolIp:
- builder.setFlowspecType(new ProtocolIpCaseBuilder().setProtocolIps(parseProtocolIp(nlri)).build());
- break;
- case Port:
- builder.setFlowspecType(new PortCaseBuilder().setPorts(parsePort(nlri)).build());
- break;
- case DestinationPort:
- builder.setFlowspecType(new DestinationPortCaseBuilder().setDestinationPorts(parseDestinationPort(nlri)).build());
- break;
- case SourcePort:
- builder.setFlowspecType(new SourcePortCaseBuilder().setSourcePorts(parseSourcePort(nlri)).build());
- break;
- case IcmpType:
- builder.setFlowspecType(new IcmpTypeCaseBuilder().setTypes(parseIcmpType(nlri)).build());
- break;
- case IcmpCode:
- builder.setFlowspecType(new IcmpCodeCaseBuilder().setCodes(parseIcmpCode(nlri)).build());
- break;
- case TcpFlags:
- builder.setFlowspecType(new TcpFlagsCaseBuilder().setTcpFlags(parseTcpFlags(nlri)).build());
- break;
- case PacketLength:
- builder.setFlowspecType(new PacketLengthCaseBuilder().setPacketLengths(parsePacketLength(nlri)).build());
- break;
- case Dscp:
- builder.setFlowspecType(new DscpCaseBuilder().setDscps(parseDscp(nlri)).build());
- break;
- case Fragment:
- builder.setFlowspecType(new FragmentCaseBuilder().setFragments(parseFragment(nlri)).build());
- break;
- default:
- break;
- }
+ setFlowspecType(builder, type, nlri);
fss.add(builder.build());
}
return fss;
}
+ private static void setFlowspecType(final FlowspecBuilder builder, final ComponentType type, final ByteBuf nlri) {
+ switch (type) {
+ case DestinationPrefix:
+ builder.setFlowspecType(new DestinationPrefixCaseBuilder().setDestinationPrefix(Ipv4Util.prefixForByteBuf(nlri)).build());
+ break;
+ case SourcePrefix:
+ builder.setFlowspecType(new SourcePrefixCaseBuilder().setSourcePrefix(Ipv4Util.prefixForByteBuf(nlri)).build());
+ break;
+ case ProtocolIp:
+ builder.setFlowspecType(new ProtocolIpCaseBuilder().setProtocolIps(parseProtocolIp(nlri)).build());
+ break;
+ case Port:
+ builder.setFlowspecType(new PortCaseBuilder().setPorts(parsePort(nlri)).build());
+ break;
+ case DestinationPort:
+ builder.setFlowspecType(new DestinationPortCaseBuilder().setDestinationPorts(parseDestinationPort(nlri)).build());
+ break;
+ case SourcePort:
+ builder.setFlowspecType(new SourcePortCaseBuilder().setSourcePorts(parseSourcePort(nlri)).build());
+ break;
+ case IcmpType:
+ builder.setFlowspecType(new IcmpTypeCaseBuilder().setTypes(parseIcmpType(nlri)).build());
+ break;
+ case IcmpCode:
+ builder.setFlowspecType(new IcmpCodeCaseBuilder().setCodes(parseIcmpCode(nlri)).build());
+ break;
+ case TcpFlags:
+ builder.setFlowspecType(new TcpFlagsCaseBuilder().setTcpFlags(parseTcpFlags(nlri)).build());
+ break;
+ case PacketLength:
+ builder.setFlowspecType(new PacketLengthCaseBuilder().setPacketLengths(parsePacketLength(nlri)).build());
+ break;
+ case Dscp:
+ builder.setFlowspecType(new DscpCaseBuilder().setDscps(parseDscp(nlri)).build());
+ break;
+ case Fragment:
+ builder.setFlowspecType(new FragmentCaseBuilder().setFragments(parseFragment(nlri)).build());
+ break;
+ default:
+ break;
+ }
+ }
+
private static List<ProtocolIps> parseProtocolIp(final ByteBuf nlri) {
final List<ProtocolIps> ips = new ArrayList<>();
boolean end = false;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.path.computation.client.ReportedLsp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.path.computation.client.ReportedLspBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.path.computation.client.StatefulTlvBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.path.computation.client.reported.lsp.Path;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
final PlspId plspid = lsp.getPlspId();
if (!lsp.isSync() && (lsp.getPlspId() == null || plspid.getValue() == 0)) {
stateSynchronizationAchieved(ctx);
- return true; //continue;
+ return true;
}
final ReportedLspBuilder rlb = new ReportedLspBuilder();
boolean solicited = false;
return false;
}
}
+ rlb.setPath(Collections.singletonList(buildPath(report, srp, plspid, lsp)));
+
+ String name = lookupLspName(plspid);
+ if (report.getLsp().getTlvs() != null && report.getLsp().getTlvs().getSymbolicPathName() != null) {
+ name = Charsets.UTF_8.decode(ByteBuffer.wrap(report.getLsp().getTlvs().getSymbolicPathName().getPathName().getValue())).toString();
+ }
+ updateLsp(ctx, plspid, name, rlb, solicited, lsp.isRemove());
+ LOG.debug("LSP {} updated", lsp);
+ return true;
+ }
+
+ private Path buildPath(final Reports report, final Srp srp, final PlspId plspid, final Lsp lsp) {
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.path.computation.client.reported.lsp.PathBuilder pb = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.path.computation.client.reported.lsp.PathBuilder();
if (report.getPath() != null) {
pb.fieldsFrom(report.getPath());
pst = null;
}
pb.addAugmentation(Path1.class, p1Builder.build());
- String name = lookupLspName(plspid);
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.object.lsp.Tlvs tlvs = report.getLsp().getTlvs();
if (tlvs != null) {
if (tlvs.getLspIdentifiers() != null) {
} else if (!isDefaultPST(pst)) {
pb.setLspId(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.LspId(lsp.getPlspId().getValue()));
}
- if (tlvs.getSymbolicPathName() != null) {
- name = Charsets.UTF_8.decode(ByteBuffer.wrap(tlvs.getSymbolicPathName().getPathName().getValue())).toString();
- }
}
- rlb.setPath(Collections.singletonList(pb.build()));
- updateLsp(ctx, plspid, name, rlb, solicited, lsp.isRemove());
- LOG.debug("LSP {} updated", lsp);
- return true;
+ return pb.build();
}
@Override
}
private SupportingNode createSupportingNode(final NodeId sni, final Boolean inControl) {
- final SupportingNodeKey sk = new SupportingNodeKey(sni, source);
+ final SupportingNodeKey sk = new SupportingNodeKey(sni, this.source);
final SupportingNodeBuilder snb = new SupportingNodeBuilder();
snb.setNodeRef(sni);
snb.setKey(sk);
}
// We now have list of all affected LSPs. Walk them create/remove them
+ updateTransaction(trans, lsps, o, u, c);
+
+ Futures.addCallback(JdkFutureAdapters.listenInPoolThread(trans.submit()), new FutureCallback<Void>() {
+ @Override
+ public void onSuccess(final Void result) {
+ LOG.trace("Topology change committed successfully");
+ }
+
+ @Override
+ public void onFailure(final Throwable t) {
+ LOG.error("Failed to propagate a topology change, target topology became inconsistent", t);
+ }
+ });
+ }
+
+ private void updateTransaction(final ReadWriteTransaction trans, final Set<InstanceIdentifier<ReportedLsp>> lsps,
+ final Map<InstanceIdentifier<?>, ? extends DataObject> old, final Map<InstanceIdentifier<?>, DataObject> updated,
+ final Map<InstanceIdentifier<?>, DataObject> created) {
+
for (final InstanceIdentifier<ReportedLsp> i : lsps) {
- final ReportedLsp oldValue = (ReportedLsp) o.get(i);
- ReportedLsp newValue = (ReportedLsp) u.get(i);
+ final ReportedLsp oldValue = (ReportedLsp) old.get(i);
+ ReportedLsp newValue = (ReportedLsp) updated.get(i);
if (newValue == null) {
- newValue = (ReportedLsp) c.get(i);
+ newValue = (ReportedLsp) created.get(i);
}
LOG.debug("Updating lsp {} value {} -> {}", i, oldValue, newValue);
}
}
}
-
- Futures.addCallback(JdkFutureAdapters.listenInPoolThread(trans.submit()), new FutureCallback<Void>() {
- @Override
- public void onSuccess(final Void result) {
- LOG.trace("Topology change committed successfully");
- }
-
- @Override
- public void onFailure(final Throwable t) {
- LOG.error("Failed to propagate a topology change, target topology became inconsistent", t);
- }
- });
}
public static InstanceIdentifier<Link> linkIdentifier(final InstanceIdentifier<Topology> topology, final NodeId node, final String name) {