Move PCE label handling from APP to protocol.
Change-Id: I26ae21b27ac2dc9ae3302030f6860e0e371c342c
diff --git a/providers/bgp/app/app.xml b/providers/bgp/app/app.xml
index 92ebbf6..ddf438a 100755
--- a/providers/bgp/app/app.xml
+++ b/providers/bgp/app/app.xml
@@ -22,6 +22,15 @@
<artifact>mvn:${project.groupId}/onos-bgpio/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-bgp-api/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-bgp-ctl/${project.version}</artifact>
+ <artifact>mvn:${project.groupId}/onos-pcep-controller-api/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-bgp-provider-topology/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-bgp-provider-cfg/${project.version}</artifact>
+ <artifact>mvn:${project.groupId}/onos-pcepio/${project.version}</artifact>
+ <artifact>mvn:${project.groupId}/onos-app-pcep-api/${project.version}</artifact>
+ <artifact>mvn:${project.groupId}/onos-pcep-controller-impl/${project.version}</artifact>
+ <artifact>mvn:${project.groupId}/onos-pcep-provider-topology/${project.version}</artifact>
+ <artifact>mvn:${project.groupId}/onos-pcep-provider-tunnel/${project.version}</artifact>
+ <artifact>mvn:${project.groupId}/onos-app-pce/${project.version}</artifact>
+ <artifact>mvn:${project.groupId}/onos-app-pceweb/${project.version}</artifact>
+ <artifact>mvn:${project.groupId}/onos-app-pcerest/${project.version}</artifact>
</app>
diff --git a/providers/bgp/app/features.xml b/providers/bgp/app/features.xml
index 9a2a032..3bace0e 100755
--- a/providers/bgp/app/features.xml
+++ b/providers/bgp/app/features.xml
@@ -21,7 +21,16 @@
<bundle>mvn:${project.groupId}/onos-bgpio/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-bgp-api/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-bgp-ctl/${project.version}</bundle>
+ <bundle>mvn:${project.groupId}/onos-pcep-controller-api/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-bgp-provider-topology/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-bgp-provider-cfg/${project.version}</bundle>
+ <bundle>mvn:${project.groupId}/onos-pcepio/${project.version}</bundle>
+ <bundle>mvn:${project.groupId}/onos-app-pcep-api/${project.version}</bundle>
+ <bundle>mvn:${project.groupId}/onos-pcep-controller-impl/${project.version}</bundle>
+ <bundle>mvn:${project.groupId}/onos-pcep-provider-topology/${project.version}</bundle>
+ <bundle>mvn:${project.groupId}/onos-pcep-provider-tunnel/${project.version}</bundle>
+ <bundle>mvn:${project.groupId}/onos-app-pce/${project.version}</bundle>
+ <bundle>mvn:${project.groupId}/onos-app-pceweb/${project.version}</bundle>
+ <bundle>mvn:${project.groupId}/onos-app-pcerest/${project.version}</bundle>
</feature>
</features>
diff --git a/providers/bgp/app/pom.xml b/providers/bgp/app/pom.xml
index a188bc2..f7daea0 100755
--- a/providers/bgp/app/pom.xml
+++ b/providers/bgp/app/pom.xml
@@ -46,5 +46,20 @@
<artifactId>onos-bgp-provider-topology</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-app-pce</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-app-pceweb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-app-pcerest</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
</project>
diff --git a/providers/bgpcep/BUCK b/providers/bgpcep/BUCK
index decfdbe..97fb3d1 100644
--- a/providers/bgpcep/BUCK
+++ b/providers/bgpcep/BUCK
@@ -10,7 +10,6 @@
'//protocols/pcep/ctl:onos-protocols-pcep-ctl',
'//providers/pcep/topology:onos-providers-pcep-topology',
'//providers/pcep/tunnel:onos-providers-pcep-tunnel',
- '//providers/pcep/packet:onos-providers-pcep-packet',
'//providers/bgpcep/flow:onos-providers-bgpcep-flow',
'//apps/pce/app:onos-apps-pce-app',
'//apps/pce/pceweb:onos-apps-pce-pceweb',
diff --git a/providers/bgpcep/app/app.xml b/providers/bgpcep/app/app.xml
index 6e24243..4e7dadb 100644
--- a/providers/bgpcep/app/app.xml
+++ b/providers/bgpcep/app/app.xml
@@ -30,7 +30,6 @@
<artifact>mvn:${project.groupId}/onos-pcep-controller-impl/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-pcep-provider-topology/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-pcep-provider-tunnel/${project.version}</artifact>
- <artifact>mvn:${project.groupId}/onos-pcep-provider-packet/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-bgpcep-provider-flow/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-app-pce/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-app-pceweb/${project.version}</artifact>
diff --git a/providers/bgpcep/app/features.xml b/providers/bgpcep/app/features.xml
index e76c58d..444a43f 100644
--- a/providers/bgpcep/app/features.xml
+++ b/providers/bgpcep/app/features.xml
@@ -31,7 +31,6 @@
<bundle>mvn:${project.groupId}/onos-pcep-provider-tunnel/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-app-pce/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-app-pceweb/${project.version}</bundle>
- <bundle>mvn:${project.groupId}/onos-pcep-provider-packet/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-bgpcep-provider-flow/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-app-pcerest/${project.version}</bundle>
</feature>
diff --git a/providers/bgpcep/flow/src/main/java/org/onosproject/provider/bgpcep/flow/impl/BgpcepFlowRuleProvider.java b/providers/bgpcep/flow/src/main/java/org/onosproject/provider/bgpcep/flow/impl/BgpcepFlowRuleProvider.java
index fd141f7..cf46cdf 100644
--- a/providers/bgpcep/flow/src/main/java/org/onosproject/provider/bgpcep/flow/impl/BgpcepFlowRuleProvider.java
+++ b/providers/bgpcep/flow/src/main/java/org/onosproject/provider/bgpcep/flow/impl/BgpcepFlowRuleProvider.java
@@ -15,95 +15,22 @@
*/
package org.onosproject.provider.bgpcep.flow.impl;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MplsLabel;
-import org.onosproject.bgp.controller.BgpController;
import org.onosproject.core.ApplicationId;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.incubator.net.tunnel.TunnelService;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
-import org.onosproject.net.Path;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.flow.CompletedBatchOperation;
-import org.onosproject.net.flow.DefaultFlowEntry;
-import org.onosproject.net.flow.FlowEntry;
import org.onosproject.net.flow.FlowRule;
-import org.onosproject.net.flow.FlowRuleBatchEntry;
import org.onosproject.net.flow.FlowRuleBatchOperation;
import org.onosproject.net.flow.FlowRuleProvider;
import org.onosproject.net.flow.FlowRuleProviderRegistry;
import org.onosproject.net.flow.FlowRuleProviderService;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.FlowEntry.FlowEntryState;
-import org.onosproject.net.flow.criteria.Criterion;
-import org.onosproject.net.flow.criteria.IPCriterion;
-import org.onosproject.net.flow.criteria.MetadataCriterion;
-import org.onosproject.net.flow.criteria.MplsBosCriterion;
-import org.onosproject.net.flow.criteria.MplsCriterion;
-import org.onosproject.net.flow.criteria.PortCriterion;
-import org.onosproject.net.flow.criteria.TunnelIdCriterion;
import org.onosproject.net.provider.AbstractProvider;
import org.onosproject.net.provider.ProviderId;
-import org.onosproject.net.resource.ResourceService;
-import org.onosproject.pcep.controller.PccId;
-import org.onosproject.pcep.controller.PcepClient;
-import org.onosproject.pcep.controller.PcepClientController;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepEroObject;
-import org.onosproject.pcepio.protocol.PcepFecObjectIPv4;
-import org.onosproject.pcepio.protocol.PcepFecObjectIPv4Adjacency;
-import org.onosproject.pcepio.protocol.PcepLabelObject;
-import org.onosproject.pcepio.protocol.PcepLabelUpdate;
-import org.onosproject.pcepio.protocol.PcepLabelUpdateMsg;
-import org.onosproject.pcepio.protocol.PcepLspObject;
-import org.onosproject.pcepio.protocol.PcepMsgPath;
-import org.onosproject.pcepio.protocol.PcepSrpObject;
-import org.onosproject.pcepio.protocol.PcepUpdateMsg;
-import org.onosproject.pcepio.protocol.PcepUpdateRequest;
-import org.onosproject.pcepio.types.IPv4SubObject;
-import org.onosproject.pcepio.types.NexthopIPv4addressTlv;
-import org.onosproject.pcepio.types.PathSetupTypeTlv;
-import org.onosproject.pcepio.types.PcepLabelDownload;
-import org.onosproject.pcepio.types.PcepLabelMap;
-import org.onosproject.pcepio.types.PcepValueType;
-import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv;
-import org.onosproject.pcepio.types.SymbolicPathNameTlv;
-import org.onosproject.pcep.controller.LspType;
-import org.onosproject.pcepio.protocol.PcepAttribute;
-import org.onosproject.pcepio.protocol.PcepBandwidthObject;
-import org.onosproject.pcep.controller.SrpIdGenerators;
-import org.onosproject.pcep.controller.PcepAnnotationKeys;
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
-import static org.onosproject.pcep.controller.PcepAnnotationKeys.BANDWIDTH;
-import static org.onosproject.pcep.controller.PcepAnnotationKeys.DELEGATE;
-import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE;
-import static org.onosproject.pcep.controller.PcepAnnotationKeys.PCE_INIT;
-import static org.onosproject.pcep.controller.PcepSyncStatus.IN_SYNC;
-import static org.onosproject.pcep.controller.PcepSyncStatus.SYNCED;
-import static org.onosproject.net.flow.criteria.Criterion.Type.EXTENSION;
-import static com.google.common.base.Preconditions.checkNotNull;
import static org.slf4j.LoggerFactory.getLogger;
/**
@@ -118,34 +45,7 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected FlowRuleProviderRegistry providerRegistry;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected BgpController bgpController;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected PcepClientController pcepController;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected ResourceService resourceService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected TunnelService tunnelService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected DeviceService deviceService;
-
private FlowRuleProviderService providerService;
- private PcepLabelObject labelObj;
- public static final int OUT_LABEL_TYPE = 0;
- public static final int IN_LABEL_TYPE = 1;
- public static final long IDENTIFIER_SET = 0x100000000L;
- public static final long SET = 0xFFFFFFFFL;
- private static final String LSRID = "lsrId";
-
- private enum PcepFlowType {
- ADD,
- MODIFY,
- REMOVE
- }
/**
* Creates a BgpFlow host provider.
@@ -169,469 +69,25 @@
@Override
public void applyFlowRule(FlowRule... flowRules) {
- for (FlowRule flowRule : flowRules) {
- processRule(flowRule, PcepFlowType.ADD);
- }
+ // TODO Auto-generated method stub
+
}
@Override
public void removeFlowRule(FlowRule... flowRules) {
- for (FlowRule flowRule : flowRules) {
- processRule(flowRule, PcepFlowType.REMOVE);
- }
- }
-
- private void processRule(FlowRule flowRule, PcepFlowType type) {
- MplsLabel mplsLabel = null;
- IpPrefix ip4PrefixSrc = null;
- IpPrefix ip4PrefixDst = null;
- PortNumber port = null;
- TunnelId tunnelId = null;
- long labelType = 0;
- boolean bottomOfStack = false;
-
- TrafficSelector selector = flowRule.selector();
- for (Criterion c : selector.criteria()) {
- switch (c.type()) {
- case MPLS_LABEL:
- MplsCriterion lc = (MplsCriterion) c;
- mplsLabel = lc.label();
- break;
- case IPV4_SRC:
- IPCriterion ipCriterion = (IPCriterion) c;
- ip4PrefixSrc = ipCriterion.ip().getIp4Prefix();
- break;
- case IPV4_DST:
- ipCriterion = (IPCriterion) c;
- ip4PrefixDst = ipCriterion.ip().getIp4Prefix();
- break;
- case IN_PORT:
- PortCriterion inPort = (PortCriterion) c;
- port = inPort.port();
- break;
- case TUNNEL_ID:
- TunnelIdCriterion tc = (TunnelIdCriterion) c;
- tunnelId = TunnelId.valueOf(String.valueOf(tc.tunnelId()));
- break;
- case METADATA:
- MetadataCriterion metadata = (MetadataCriterion) c;
- labelType = metadata.metadata();
- break;
- case MPLS_BOS:
- MplsBosCriterion mplsBos = (MplsBosCriterion) c;
- bottomOfStack = mplsBos.mplsBos();
- break;
- default:
- break;
- }
- }
-
- checkNotNull(mplsLabel);
- LabelResourceId label = LabelResourceId.labelResourceId(mplsLabel.toInt());
-
- try {
- if (tunnelId != null) {
- pushLocalLabels(flowRule.deviceId(), label, port, tunnelId, bottomOfStack, labelType, type);
- return;
- }
-
- if (ip4PrefixDst != null) {
- pushAdjacencyLabel(flowRule.deviceId(), label, ip4PrefixSrc, ip4PrefixDst, type);
- return;
- }
-
- pushGlobalNodeLabel(flowRule.deviceId(), label, ip4PrefixSrc, type, bottomOfStack);
-
- } catch (PcepParseException e) {
- log.error("Exception occured while sending label message to PCC {}", e.getMessage());
- }
-
- }
-
- /**
- * Returns PCEP client.
- *
- * @return PCEP client
- */
- private PcepClient getPcepClient(DeviceId deviceId) {
- Device device = deviceService.getDevice(deviceId);
-
- // In future projections instead of annotations will be used to fetch LSR ID.
- String lsrId = device.annotations().value(LSRID);
-
- PcepClient pcc = pcepController.getClient(PccId.pccId(IpAddress.valueOf(lsrId)));
- return pcc;
- }
-
- //Pushes node labels to the specified device.
- private void pushGlobalNodeLabel(DeviceId deviceId, LabelResourceId labelId,
- IpPrefix ipPrefix, PcepFlowType type, boolean isBos) throws PcepParseException {
-
- checkNotNull(deviceId);
- checkNotNull(labelId);
- checkNotNull(type);
-
- PcepClient pc = getPcepClient(deviceId);
- if (pc == null) {
- log.error("PCEP client not found");
- return;
- }
-
- LinkedList<PcepLabelUpdate> labelUpdateList = new LinkedList<>();
-
- if (ipPrefix == null) {
- // Pushing self node label to device.
- ipPrefix = IpPrefix.valueOf(pc.getPccId().ipAddress(), 32);
- }
-
- PcepFecObjectIPv4 fecObject = pc.factory().buildFecObjectIpv4()
- .setNodeID(ipPrefix.address().getIp4Address().toInt())
- .build();
-
- boolean bSFlag = false;
- if (pc.labelDbSyncStatus() == IN_SYNC && !isBos) {
- // Need to set sync flag in all messages till sync completes.
- bSFlag = true;
- }
-
- PcepSrpObject srpObj = getSrpObject(pc, type, bSFlag);
-
- //Global NODE-SID as label object
- PcepLabelObject labelObject = pc.factory().buildLabelObject()
- .setLabel((int) labelId.labelId())
- .build();
-
- PcepLabelMap labelMap = new PcepLabelMap();
- labelMap.setFecObject(fecObject);
- labelMap.setLabelObject(labelObject);
- labelMap.setSrpObject(srpObj);
-
- labelUpdateList.add(pc.factory().buildPcepLabelUpdateObject()
- .setLabelMap(labelMap)
- .build());
-
- PcepLabelUpdateMsg labelMsg = pc.factory().buildPcepLabelUpdateMsg()
- .setPcLabelUpdateList(labelUpdateList)
- .build();
-
- pc.sendMessage(labelMsg);
-
- if (isBos) {
- // Sync is completed.
- pc.setLabelDbSyncStatus(SYNCED);
- }
- }
-
- private PcepSrpObject getSrpObject(PcepClient pc, PcepFlowType type, boolean bSFlag)
- throws PcepParseException {
- PcepSrpObject srpObj;
- boolean bRFlag = false;
-
- if (!type.equals(PcepFlowType.ADD)) {
- // To cleanup labels, R bit is set
- bRFlag = true;
- }
-
- srpObj = pc.factory().buildSrpObject()
- .setRFlag(bRFlag)
- .setSFlag(bSFlag)
- .setSrpID(SrpIdGenerators.create())
- .build();
-
- return srpObj;
- }
-
- //Pushes adjacency labels to the specified device.
- private void pushAdjacencyLabel(DeviceId deviceId, LabelResourceId labelId, IpPrefix ip4PrefixSrc,
- IpPrefix ip4PrefixDst, PcepFlowType type)
- throws PcepParseException {
-
- checkNotNull(deviceId);
- checkNotNull(labelId);
- checkNotNull(ip4PrefixSrc);
- checkNotNull(ip4PrefixDst);
- checkNotNull(type);
-
- PcepClient pc = getPcepClient(deviceId);
- if (pc == null) {
- log.error("PCEP client not found");
- return;
- }
-
- LinkedList<PcepLabelUpdate> labelUpdateList = new LinkedList<>();
-
- int srcPortNo = ip4PrefixSrc.address().getIp4Address().toInt();
- int dstPortNo = ip4PrefixDst.address().getIp4Address().toInt();
-
- PcepFecObjectIPv4Adjacency fecAdjObject = pc.factory().buildFecIpv4Adjacency()
- .seRemoteIPv4Address(dstPortNo)
- .seLocalIPv4Address(srcPortNo)
- .build();
-
- boolean bSFlag = false;
- if (pc.labelDbSyncStatus() == IN_SYNC) {
- // Need to set sync flag in all messages till sync completes.
- bSFlag = true;
- }
-
- PcepSrpObject srpObj = getSrpObject(pc, type, bSFlag);
-
- //Adjacency label object
- PcepLabelObject labelObject = pc.factory().buildLabelObject()
- .setLabel((int) labelId.labelId())
- .build();
-
- PcepLabelMap labelMap = new PcepLabelMap();
- labelMap.setFecObject(fecAdjObject);
- labelMap.setLabelObject(labelObject);
- labelMap.setSrpObject(srpObj);
-
- labelUpdateList.add(pc.factory().buildPcepLabelUpdateObject()
- .setLabelMap(labelMap)
- .build());
-
- PcepLabelUpdateMsg labelMsg = pc.factory().buildPcepLabelUpdateMsg()
- .setPcLabelUpdateList(labelUpdateList)
- .build();
-
- pc.sendMessage(labelMsg);
- }
-
- //Pushes local labels to the device which is specific to path [CR-case].
- private void pushLocalLabels(DeviceId deviceId, LabelResourceId labelId,
- PortNumber portNum, TunnelId tunnelId,
- Boolean isBos, Long labelType, PcepFlowType type) throws PcepParseException {
-
- checkNotNull(deviceId);
- checkNotNull(labelId);
- checkNotNull(portNum);
- checkNotNull(tunnelId);
- checkNotNull(labelType);
- checkNotNull(type);
-
- PcepClient pc = getPcepClient(deviceId);
- if (pc == null) {
- log.error("PCEP client not found");
- return;
- }
-
- PcepLspObject lspObj;
- LinkedList<PcepLabelUpdate> labelUpdateList = new LinkedList<>();
- LinkedList<PcepLabelObject> labelObjects = new LinkedList<>();
- PcepSrpObject srpObj;
- PcepLabelDownload labelDownload = new PcepLabelDownload();
- LinkedList<PcepValueType> optionalTlv = new LinkedList<>();
-
- long portNo = portNum.toLong();
- portNo = ((portNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? portNo & SET : portNo;
-
- optionalTlv.add(NexthopIPv4addressTlv.of((int) portNo));
-
- Tunnel tunnel = tunnelService.queryTunnel(tunnelId);
-
- PcepLabelObject labelObj = pc.factory().buildLabelObject()
- .setOFlag(labelType == OUT_LABEL_TYPE)
- .setOptionalTlv(optionalTlv)
- .setLabel((int) labelId.labelId())
- .build();
-
- /**
- * Check whether transit node or not. For transit node, label update message should include IN and OUT labels.
- * Hence store IN label object and next when out label comes add IN and OUT label objects and encode label
- * update message and send to specified client.
- */
- if (!deviceId.equals(tunnel.path().src().deviceId()) && !deviceId.equals(tunnel.path().dst().deviceId())) {
- //Device is transit node
- if (labelType == IN_LABEL_TYPE) {
- //Store label object having IN label value
- this.labelObj = labelObj;
- return;
- }
- //Add IN label object
- labelObjects.add(this.labelObj);
- }
-
- //Add OUT label object in case of transit node
- labelObjects.add(labelObj);
-
- srpObj = getSrpObject(pc, type, false);
-
- String lspId = tunnel.annotations().value(PcepAnnotationKeys.LOCAL_LSP_ID);
- String plspId = tunnel.annotations().value(PcepAnnotationKeys.PLSP_ID);
- String tunnelIdentifier = tunnel.annotations().value(PcepAnnotationKeys.PCC_TUNNEL_ID);
-
- LinkedList<PcepValueType> tlvs = new LinkedList<>();
- StatefulIPv4LspIdentifiersTlv lspIdTlv = new StatefulIPv4LspIdentifiersTlv(((IpTunnelEndPoint) tunnel.src())
- .ip().getIp4Address().toInt(), Short.valueOf(lspId), Short.valueOf(tunnelIdentifier),
- ((IpTunnelEndPoint) tunnel.src()).ip().getIp4Address().toInt(),
- ((IpTunnelEndPoint) tunnel.dst()).ip().getIp4Address().toInt());
- tlvs.add(lspIdTlv);
-
- if (tunnel.tunnelName().value() != null) {
- SymbolicPathNameTlv pathNameTlv = new SymbolicPathNameTlv(tunnel.tunnelName().value().getBytes());
- tlvs.add(pathNameTlv);
- }
-
- boolean delegated = (tunnel.annotations().value(DELEGATE) == null) ? false
- : Boolean.valueOf(tunnel.annotations()
- .value(DELEGATE));
- boolean initiated = (tunnel.annotations().value(PCE_INIT) == null) ? false
- : Boolean.valueOf(tunnel.annotations()
- .value(PCE_INIT));
-
- lspObj = pc.factory().buildLspObject()
- .setRFlag(false)
- .setAFlag(true)
- .setDFlag(delegated)
- .setCFlag(initiated)
- .setPlspId(Integer.valueOf(plspId))
- .setOptionalTlv(tlvs)
- .build();
-
- labelDownload.setLabelList(labelObjects);
- labelDownload.setLspObject(lspObj);
- labelDownload.setSrpObject(srpObj);
-
- labelUpdateList.add(pc.factory().buildPcepLabelUpdateObject()
- .setLabelDownload(labelDownload)
- .build());
-
- PcepLabelUpdateMsg labelMsg = pc.factory().buildPcepLabelUpdateMsg()
- .setPcLabelUpdateList(labelUpdateList)
- .build();
-
- pc.sendMessage(labelMsg);
-
- //If isBos is true, label download is done along the LSP, send PCEP update message.
- if (isBos) {
- sendPcepUpdateMsg(pc, lspObj, tunnel);
- }
- }
-
- //Sends PCEP update message.
- private void sendPcepUpdateMsg(PcepClient pc, PcepLspObject lspObj, Tunnel tunnel) throws PcepParseException {
- LinkedList<PcepUpdateRequest> updateRequestList = new LinkedList<>();
- LinkedList<PcepValueType> subObjects = createEroSubObj(tunnel.path());
-
- if (subObjects == null) {
- log.error("ERO subjects not present");
- return;
- }
-
- // set PathSetupTypeTlv of SRP object
- LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>();
- LspType lspSigType = LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE));
- llOptionalTlv.add(new PathSetupTypeTlv(lspSigType.type()));
-
- PcepSrpObject srpObj = pc.factory().buildSrpObject()
- .setRFlag(false)
- .setSrpID(SrpIdGenerators.create())
- .setOptionalTlv(llOptionalTlv)
- .build();
-
- PcepEroObject eroObj = pc.factory().buildEroObject()
- .setSubObjects(subObjects)
- .build();
-
- float iBandwidth = 0;
- if (tunnel.annotations().value(BANDWIDTH) != null) {
- //iBandwidth = Float.floatToIntBits(Float.parseFloat(tunnel.annotations().value(BANDWIDTH)));
- iBandwidth = Float.parseFloat(tunnel.annotations().value(BANDWIDTH));
- }
- // build bandwidth object
- PcepBandwidthObject bandwidthObject = pc.factory().buildBandwidthObject()
- .setBandwidth(iBandwidth)
- .build();
- // build pcep attribute
- PcepAttribute pcepAttribute = pc.factory().buildPcepAttribute()
- .setBandwidthObject(bandwidthObject)
- .build();
-
- PcepMsgPath msgPath = pc.factory().buildPcepMsgPath()
- .setEroObject(eroObj)
- .setPcepAttribute(pcepAttribute)
- .build();
-
- PcepUpdateRequest updateReq = pc.factory().buildPcepUpdateRequest()
- .setSrpObject(srpObj)
- .setMsgPath(msgPath)
- .setLspObject(lspObj)
- .build();
-
- updateRequestList.add(updateReq);
-
- //TODO: P = 1 is it P flag in PCEP obj header
- PcepUpdateMsg updateMsg = pc.factory().buildUpdateMsg()
- .setUpdateRequestList(updateRequestList)
- .build();
-
- pc.sendMessage(updateMsg);
- }
-
- private LinkedList<PcepValueType> createEroSubObj(Path path) {
- LinkedList<PcepValueType> subObjects = new LinkedList<>();
- List<Link> links = path.links();
- ConnectPoint source = null;
- ConnectPoint destination = null;
- IpAddress ipDstAddress = null;
- IpAddress ipSrcAddress = null;
- PcepValueType subObj = null;
- long portNo;
-
- for (Link link : links) {
- source = link.src();
- if (!(source.equals(destination))) {
- //set IPv4SubObject for ERO object
- portNo = source.port().toLong();
- portNo = ((portNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? portNo & SET : portNo;
- ipSrcAddress = Ip4Address.valueOf((int) portNo);
- subObj = new IPv4SubObject(ipSrcAddress.getIp4Address().toInt());
- subObjects.add(subObj);
- }
+ // TODO Auto-generated method stub
- destination = link.dst();
- portNo = destination.port().toLong();
- portNo = ((portNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? portNo & SET : portNo;
- ipDstAddress = Ip4Address.valueOf((int) portNo);
- subObj = new IPv4SubObject(ipDstAddress.getIp4Address().toInt());
- subObjects.add(subObj);
- }
- return subObjects;
}
@Override
public void removeRulesById(ApplicationId id, FlowRule... flowRules) {
- // TODO
- removeFlowRule(flowRules);
+ // TODO Auto-generated method stub
+
}
@Override
public void executeBatch(FlowRuleBatchOperation batch) {
- Collection<FlowEntry> flowEntries = new ArrayList<>();
+ // TODO Auto-generated method stub
- for (FlowRuleBatchEntry fbe : batch.getOperations()) {
- Criterion criteria = fbe.target().selector().getCriterion(EXTENSION);
-
- switch (fbe.operator()) {
- case ADD:
- if (criteria == null) {
- processRule(fbe.target(), PcepFlowType.ADD);
- flowEntries.add(new DefaultFlowEntry(fbe.target(), FlowEntryState.ADDED, 0, 0, 0));
- }
- break;
- case REMOVE:
- if (criteria == null) {
- processRule(fbe.target(), PcepFlowType.REMOVE);
- flowEntries.add(new DefaultFlowEntry(fbe.target(), FlowEntryState.REMOVED, 0, 0, 0));
- }
- break;
- default:
- log.error("Unknown flow operation: {}", fbe);
- }
- }
-
- CompletedBatchOperation status = new CompletedBatchOperation(true, Collections.emptySet(), batch.deviceId());
- providerService.batchOperationCompleted(batch.id(), status);
- providerService.pushFlowMetrics(batch.deviceId(), flowEntries);
}
}
diff --git a/providers/pcep/BUCK b/providers/pcep/BUCK
index bcf6c31..c5b609d 100644
--- a/providers/pcep/BUCK
+++ b/providers/pcep/BUCK
@@ -5,7 +5,6 @@
'//protocols/pcep/pcepio:onos-protocols-pcep-pcepio',
'//protocols/pcep/ctl:onos-protocols-pcep-ctl',
'//apps/pcep-api:onos-apps-pcep-api',
- '//providers/pcep/packet:onos-providers-pcep-packet',
]
onos_app (
diff --git a/providers/pcep/packet/BUCK b/providers/pcep/packet/BUCK
deleted file mode 100644
index 94b0e5b..0000000
--- a/providers/pcep/packet/BUCK
+++ /dev/null
@@ -1,8 +0,0 @@
-COMPILE_DEPS = [
- '//lib:CORE_DEPS',
- '//protocols/pcep/api:onos-protocols-pcep-api',
-]
-
-osgi_jar_with_tests (
- deps = COMPILE_DEPS,
-)
diff --git a/providers/pcep/packet/pom.xml b/providers/pcep/packet/pom.xml
deleted file mode 100644
index 2d32c19..0000000
--- a/providers/pcep/packet/pom.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<!--
- ~ Copyright 2016-present Open Networking Laboratory
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-pcep-providers</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
- <artifactId>onos-pcep-provider-packet</artifactId>
- <packaging>bundle</packaging>
- <description>PCEP packet provider</description>
- <dependencies>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-pcep-controller-api</artifactId>
- </dependency>
- </dependencies>
-</project>
diff --git a/providers/pcep/packet/src/main/java/org/onosproject/provider/pcep/packet/impl/PcepPacketProvider.java b/providers/pcep/packet/src/main/java/org/onosproject/provider/pcep/packet/impl/PcepPacketProvider.java
deleted file mode 100644
index a522a8f..0000000
--- a/providers/pcep/packet/src/main/java/org/onosproject/provider/pcep/packet/impl/PcepPacketProvider.java
+++ /dev/null
@@ -1,123 +0,0 @@
-package org.onosproject.provider.pcep.packet.impl;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.Service;
-import org.onlab.packet.Ethernet;
-import org.onlab.packet.IPv4;
-import org.onlab.packet.MacAddress;
-import org.onlab.packet.TCP;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.packet.DefaultInboundPacket;
-import org.onosproject.net.packet.DefaultPacketContext;
-import org.onosproject.net.packet.InboundPacket;
-import org.onosproject.net.packet.OutboundPacket;
-import org.onosproject.net.packet.PacketProvider;
-import org.onosproject.net.packet.PacketProviderRegistry;
-import org.onosproject.net.packet.PacketProviderService;
-import org.onosproject.net.provider.AbstractProvider;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.pcep.controller.PccId;
-import org.onosproject.pcep.controller.PcepClientController;
-import org.onosproject.pcep.controller.PcepPacketListener;
-import org.slf4j.Logger;
-
-/**
- * Provider which uses an PCEP controller to process packets.
- */
-@Component(immediate = true)
-@Service
-public class PcepPacketProvider extends AbstractProvider implements PacketProvider {
-
- private static final Logger log = getLogger(PcepPacketProvider.class);
- static final String PROVIDER_ID = "org.onosproject.provider.packet.pcep";
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected PacketProviderRegistry packetProviderRegistry;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected PcepClientController pcepClientController;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected DeviceService deviceService;
-
- PacketProviderService packetProviderService;
-
- private InnerPacketProvider listener = new InnerPacketProvider();
- public static final String LSRID = "lsrId";
- public static final int PCEP_PORT = 4189;
-
- /**
- * Creates a Packet provider.
- */
- public PcepPacketProvider() {
- super(new ProviderId("pcep", PROVIDER_ID));
- }
-
- @Activate
- public void activate() {
- packetProviderService = packetProviderRegistry.register(this);
- pcepClientController.addPacketListener(listener);
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- packetProviderRegistry.unregister(this);
- pcepClientController.removePacketListener(listener);
- log.info("Stopped");
- }
-
- private class InnerPacketProvider implements PcepPacketListener {
- @Override
- public void sendPacketIn(PccId pccId) {
- TCP tcp = new TCP();
- // Set the well known PCEP port. To be used to decide to process/discard the packet while processing.
- tcp.setDestinationPort(PCEP_PORT);
-
- IPv4 ipv4 = new IPv4();
- ipv4.setProtocol(IPv4.PROTOCOL_TCP);
- ipv4.setPayload(tcp);
-
- Ethernet eth = new Ethernet();
- eth.setEtherType(Ethernet.TYPE_IPV4);
- eth.setDestinationMACAddress(MacAddress.NONE);
- eth.setPayload(ipv4);
-
- // Get lsrId of the PCEP client from the PCC ID. Session info is based on lsrID.
- String lsrId = String.valueOf(pccId.ipAddress());
- DeviceId pccDeviceId = DeviceId.deviceId(lsrId);
-
- InboundPacket inPkt = new DefaultInboundPacket(new ConnectPoint(pccDeviceId,
- PortNumber.portNumber(PCEP_PORT)),
- eth, null);
-
- packetProviderService.processPacket(new PcepPacketContext(inPkt, null));
- }
- }
-
- // Minimal PacketContext to make core and applications happy.
- private final class PcepPacketContext extends DefaultPacketContext {
- private PcepPacketContext(InboundPacket inPkt, OutboundPacket outPkt) {
- super(System.currentTimeMillis(), inPkt, outPkt, false);
- }
-
- @Override
- public void send() {
- // We don't send anything out.
- }
- }
-
- @Override
- public void emit(OutboundPacket packet) {
- // Nothing to emit
- }
-}
diff --git a/providers/pcep/packet/src/main/java/org/onosproject/provider/pcep/packet/impl/package-info.java b/providers/pcep/packet/src/main/java/org/onosproject/provider/pcep/packet/impl/package-info.java
deleted file mode 100644
index 8e1ab9a..0000000
--- a/providers/pcep/packet/src/main/java/org/onosproject/provider/pcep/packet/impl/package-info.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- *Provider that uses PCEP controller as a means to send packets.
- */
-package org.onosproject.provider.pcep.packet.impl;
\ No newline at end of file
diff --git a/providers/pcep/pom.xml b/providers/pcep/pom.xml
index 03638de..7fdfc76 100644
--- a/providers/pcep/pom.xml
+++ b/providers/pcep/pom.xml
@@ -27,6 +27,5 @@
<module>topology</module>
<module>tunnel</module>
<module>app</module>
- <module>packet</module>
</modules>
</project>
\ No newline at end of file
diff --git a/providers/pcep/topology/BUCK b/providers/pcep/topology/BUCK
index 7a64a61..5b5078d 100644
--- a/providers/pcep/topology/BUCK
+++ b/providers/pcep/topology/BUCK
@@ -1,5 +1,6 @@
COMPILE_DEPS = [
'//lib:CORE_DEPS',
+ '//incubator/api:onos-incubator-api',
'//protocols/ovsdb/api:onos-protocols-ovsdb-api',
'//protocols/ovsdb/rfc:onos-protocols-ovsdb-rfc',
'//apps/pcep-api:onos-apps-pcep-api',
diff --git a/providers/pcep/topology/src/test/java/org/onosproject/provider/pcep/topology/impl/PcepClientControllerAdapter.java b/providers/pcep/topology/src/test/java/org/onosproject/provider/pcep/topology/impl/PcepClientControllerAdapter.java
index 1cf2a32..459ebc9 100644
--- a/providers/pcep/topology/src/test/java/org/onosproject/provider/pcep/topology/impl/PcepClientControllerAdapter.java
+++ b/providers/pcep/topology/src/test/java/org/onosproject/provider/pcep/topology/impl/PcepClientControllerAdapter.java
@@ -25,6 +25,10 @@
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Deactivate;
import org.onlab.packet.IpAddress;
+import org.onosproject.incubator.net.tunnel.DefaultLabelStack;
+import org.onosproject.incubator.net.tunnel.LabelStack;
+import org.onosproject.incubator.net.tunnel.Tunnel;
+import org.onosproject.net.Path;
import org.onosproject.pcep.controller.ClientCapability;
import org.onosproject.pcep.controller.PccId;
import org.onosproject.pcep.controller.PcepClient;
@@ -32,7 +36,6 @@
import org.onosproject.pcep.controller.PcepClientListener;
import org.onosproject.pcep.controller.PcepEventListener;
import org.onosproject.pcep.controller.PcepNodeListener;
-import org.onosproject.pcep.controller.PcepPacketListener;
import org.onosproject.pcep.controller.driver.PcepAgent;
import org.onosproject.pcepio.protocol.PcepError;
import org.onosproject.pcepio.protocol.PcepErrorInfo;
@@ -41,6 +44,7 @@
import org.onosproject.pcepio.protocol.PcepFactory;
import org.onosproject.pcepio.protocol.PcepMessage;
import org.onosproject.pcepio.protocol.PcepVersion;
+import org.onosproject.pcepio.types.PcepValueType;
import com.google.common.collect.Sets;
@@ -290,14 +294,20 @@
}
@Override
- public void addPacketListener(PcepPacketListener listener) {
+ public LabelStack computeLabelStack(Path path) {
// TODO Auto-generated method stub
-
+ return null;
}
@Override
- public void removePacketListener(PcepPacketListener listener) {
+ public LinkedList<PcepValueType> createPcepLabelStack(DefaultLabelStack labelStack, Path path) {
// TODO Auto-generated method stub
+ return null;
+ }
+ @Override
+ public boolean allocateLocalLabel(Tunnel tunnel) {
+ // TODO Auto-generated method stub
+ return false;
}
}
diff --git a/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProvider.java b/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProvider.java
index f821f21..767d026 100644
--- a/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProvider.java
+++ b/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProvider.java
@@ -100,7 +100,6 @@
import org.onosproject.pcepio.protocol.PcepMessage;
import org.onosproject.pcepio.protocol.PcepMetricObject;
import org.onosproject.pcepio.protocol.PcepMsgPath;
-import org.onosproject.pcepio.protocol.PcepNai;
import org.onosproject.pcepio.protocol.PcepReportMsg;
import org.onosproject.pcepio.protocol.PcepSrpObject;
import org.onosproject.pcepio.protocol.PcepStateReport;
@@ -109,7 +108,6 @@
import org.onosproject.pcepio.types.IPv4SubObject;
import org.onosproject.pcepio.types.PathSetupTypeTlv;
import org.onosproject.pcepio.types.PcepNaiIpv4Adjacency;
-import org.onosproject.pcepio.types.PcepNaiIpv4NodeId;
import org.onosproject.pcepio.types.PcepValueType;
import org.onosproject.pcepio.types.SrEroSubObject;
import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv;
@@ -124,7 +122,6 @@
import java.util.Collections;
import java.util.Dictionary;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
@@ -280,7 +277,6 @@
collectors.values().forEach(tsc -> tsc.adjustPollInterval(tunnelStatsPollFrequency));
log.info("New setting: tunnelStatsPollFrequency={}", tunnelStatsPollFrequency);
}
-
}
@Override
@@ -318,8 +314,27 @@
//TODO: tunnel which is passed doesn't have tunnelID
if (tunnel.annotations().value(PLSP_ID) != null) {
if (LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE)) != WITHOUT_SIGNALLING_AND_WITHOUT_SR) {
- // For CR LSPs, BGP flow provider will send update message after pushing labels.
updateTunnel(tunnel, path);
+ } else {
+ // Download labels and send update message.
+ // To get new tunnel ID (modified tunnel ID)
+ Collection<Tunnel> tunnels = tunnelService.queryTunnel(tunnel.src(), tunnel.dst());
+ for (Tunnel t : tunnels) {
+ if (t.state().equals(INIT) && t.tunnelName().equals(tunnel.tunnelName())) {
+ tunnel = new DefaultTunnel(tunnel.providerId(), tunnel.src(),
+ tunnel.dst(), tunnel.type(),
+ t.state(), tunnel.groupId(),
+ t.tunnelId(),
+ tunnel.tunnelName(),
+ tunnel.path(),
+ tunnel.resource(),
+ tunnel.annotations());
+ break;
+ }
+ }
+ if (!pcepClientController.allocateLocalLabel(tunnel)) {
+ log.error("Unable to allocate labels for the tunnel {}.", tunnel.toString());
+ }
}
return;
}
@@ -806,13 +821,11 @@
extendAnnotations);
}
- TunnelDescription tunnel = new DefaultTunnelDescription(
- tunnelId,
+ TunnelDescription tunnel = new DefaultTunnelDescription(tunnelId,
srcPoint,
dstPoint,
tunnelType,
- new DefaultGroupId(
- 0),
+ new DefaultGroupId(0),
id(), name,
path,
annotations);
@@ -904,55 +917,6 @@
}
/**
- * Creates label stack for ERO object from network resource.
- *
- * @param labelStack
- * @param path (hop list)
- * @return list of ERO subobjects
- */
- private LinkedList<PcepValueType> createPcepLabelStack(DefaultLabelStack labelStack, Path path) {
- checkNotNull(labelStack);
-
- LinkedList<PcepValueType> llSubObjects = new LinkedList<PcepValueType>();
- Iterator<Link> links = path.links().iterator();
- LabelResourceId label = null;
- Link link = null;
- PcepValueType subObj = null;
- PcepNai nai = null;
- Device dstNode = null;
- long srcPortNo, dstPortNo;
-
- ListIterator<LabelResourceId> labelListIterator = labelStack.labelResources().listIterator();
- while (labelListIterator.hasNext()) {
- label = labelListIterator.next();
- link = links.next();
-
- srcPortNo = link.src().port().toLong();
- srcPortNo = ((srcPortNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? srcPortNo & SET : srcPortNo;
-
- dstPortNo = link.dst().port().toLong();
- dstPortNo = ((dstPortNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? dstPortNo & SET : dstPortNo;
-
- nai = new PcepNaiIpv4Adjacency((int) srcPortNo, (int) dstPortNo);
- subObj = new SrEroSubObject(PcepNaiIpv4Adjacency.ST_TYPE, false, false, false, true, (int) label.labelId(),
- nai);
- llSubObjects.add(subObj);
-
- dstNode = deviceService.getDevice(link.dst().deviceId());
- nai = new PcepNaiIpv4NodeId(Ip4Address.valueOf(dstNode.annotations().value(LSRID)).toInt());
-
- if (!labelListIterator.hasNext()) {
- log.error("Malformed label stack.");
- }
- label = labelListIterator.next();
- subObj = new SrEroSubObject(PcepNaiIpv4NodeId.ST_TYPE, false, false, false, true, (int) label.labelId(),
- nai);
- llSubObjects.add(subObj);
- }
- return llSubObjects;
- }
-
- /**
* Creates PcInitiated lsp request list for setup tunnel.
*
* @param tunnel mpls tunnel
@@ -967,10 +931,18 @@
throws PcepParseException {
PcepValueType tlv;
LinkedList<PcepValueType> llSubObjects = null;
+ LspType lspType = LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE));
- NetworkResource labelStack = tunnel.resource();
- if (labelStack != null && labelStack instanceof DefaultLabelStack) {
- llSubObjects = createPcepLabelStack((DefaultLabelStack) labelStack, path);
+ if (lspType == SR_WITHOUT_SIGNALLING) {
+ NetworkResource labelStack = tunnel.resource();
+ if (labelStack == null || !(labelStack instanceof DefaultLabelStack)) {
+ labelStack = pcepClientController.computeLabelStack(tunnel.path());
+ if (labelStack == null) {
+ log.error("Unable to create label stack.");
+ return null;
+ }
+ }
+ llSubObjects = pcepClientController.createPcepLabelStack((DefaultLabelStack) labelStack, path);
} else {
llSubObjects = createPcepPath(path);
}
@@ -983,7 +955,7 @@
LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>();
// set PathSetupTypeTlv of SRP object
- tlv = new PathSetupTypeTlv(LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE)).type());
+ tlv = new PathSetupTypeTlv(lspType.type());
llOptionalTlv.add(tlv);
// build SRP object
@@ -1115,7 +1087,6 @@
PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, DELETE);
pcepTunnelApiMapper.addToCoreTunnelRequestQueue(pcepTunnelData);
int srpId = SrpIdGenerators.create();
- TunnelId tunnelId = tunnel.tunnelId();
PcepValueType tlv;
LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>();
@@ -1193,14 +1164,21 @@
PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, UPDATE);
pcepTunnelApiMapper.addToCoreTunnelRequestQueue(pcepTunnelData);
int srpId = SrpIdGenerators.create();
- TunnelId tunnelId = tunnel.tunnelId();
PcepValueType tlv;
- int plspId = 0;
LinkedList<PcepValueType> llSubObjects = null;
- NetworkResource labelStack = tunnel.resource();
- if (labelStack != null && labelStack instanceof DefaultLabelStack) {
- llSubObjects = createPcepLabelStack((DefaultLabelStack) labelStack, path);
+ LspType lspSigType = LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE));
+
+ if (lspSigType == SR_WITHOUT_SIGNALLING) {
+ NetworkResource labelStack = tunnel.resource();
+ if (labelStack == null || !(labelStack instanceof DefaultLabelStack)) {
+ labelStack = pcepClientController.computeLabelStack(tunnel.path());
+ if (labelStack == null) {
+ log.error("Unable to create label stack.");
+ return;
+ }
+ }
+ llSubObjects = pcepClientController.createPcepLabelStack((DefaultLabelStack) labelStack, path);
} else {
llSubObjects = createPcepPath(path);
}
@@ -1209,7 +1187,6 @@
LinkedList<PcepUpdateRequest> llUpdateRequestList = new LinkedList<PcepUpdateRequest>();
// set PathSetupTypeTlv of SRP object
- LspType lspSigType = LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE));
tlv = new PathSetupTypeTlv(lspSigType.type());
llOptionalTlv.add(tlv);
@@ -1285,8 +1262,6 @@
}
}
-
-
private class InnerTunnelProvider implements PcepTunnelListener, PcepEventListener, PcepClientListener {
@Override
@@ -1302,7 +1277,6 @@
}
TunnelId tunnelId = getTunnelId(tunnelKey);
-
tunnel = buildOpticalTunnel(pcepTunnel, tunnelId);
OperationType operType = pcepTunnel.getOperationType();
@@ -1737,7 +1711,7 @@
private void tunnelUpdateInDelegatedCase(PccId pccId, SparseAnnotations annotations,
DefaultTunnelDescription td, ProviderId providerId, State tunnelState,
StatefulIPv4LspIdentifiersTlv ipv4LspIdentifiersTlv) {
- //Wait for 2sec then query tunnel based on ingress PLSP-ID and local LSP-ID
+ // Wait for 2sec then query tunnel based on ingress PLSP-ID and local LSP-ID
/*
* If ONOS is not the master for that PCC then check if D flag is set, if yes wait [while
@@ -1891,14 +1865,11 @@
if (endOfSyncAction == PcepLspSyncAction.UNSTABLE) {
-
// Send PCInit msg again after global reoptimization.
tunnelUpdated(td, UNSTABLE);
- // To remove the old tunnel from store whose PLSPID is not
- // recognized by ingress PCC.
+ // To remove the old tunnel from store whose PLSPID is not recognized by ingress PCC.
tunnelRemoved(td);
-
} else if (endOfSyncAction == REMOVE) {
tunnelRemoved(td);
}
diff --git a/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientControllerAdapter.java b/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientControllerAdapter.java
index b9c751e..a541734 100644
--- a/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientControllerAdapter.java
+++ b/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientControllerAdapter.java
@@ -24,13 +24,16 @@
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Deactivate;
+import org.onosproject.incubator.net.tunnel.DefaultLabelStack;
+import org.onosproject.incubator.net.tunnel.LabelStack;
+import org.onosproject.incubator.net.tunnel.Tunnel;
+import org.onosproject.net.Path;
import org.onosproject.pcep.controller.PccId;
import org.onosproject.pcep.controller.PcepClient;
import org.onosproject.pcep.controller.PcepClientController;
import org.onosproject.pcep.controller.PcepClientListener;
import org.onosproject.pcep.controller.PcepEventListener;
import org.onosproject.pcep.controller.PcepNodeListener;
-import org.onosproject.pcep.controller.PcepPacketListener;
import org.onosproject.pcep.controller.driver.PcepAgent;
import org.onosproject.pcepio.protocol.PcepError;
import org.onosproject.pcepio.protocol.PcepErrorInfo;
@@ -39,6 +42,7 @@
import org.onosproject.pcepio.protocol.PcepFactory;
import org.onosproject.pcepio.protocol.PcepMessage;
import org.onosproject.pcepio.protocol.PcepVersion;
+import org.onosproject.pcepio.types.PcepValueType;
import com.google.common.collect.Sets;
@@ -58,7 +62,6 @@
protected Set<PcepEventListener> pcepEventListener = Sets.newHashSet();
public Set<PcepNodeListener> pcepNodeListener = Sets.newHashSet();
- protected Set<PcepPacketListener> pcepPacketListener = Sets.newHashSet();
@Activate
public void activate() {
@@ -118,16 +121,6 @@
}
@Override
- public void addPacketListener(PcepPacketListener listener) {
- pcepPacketListener.add(listener);
- }
-
- @Override
- public void removePacketListener(PcepPacketListener listener) {
- pcepPacketListener.remove(listener);
- }
-
- @Override
public void writeMessage(PccId pccId, PcepMessage msg) {
this.getClient(pccId).sendMessage(msg);
}
@@ -292,4 +285,22 @@
return false;
}
}
+
+ @Override
+ public LabelStack computeLabelStack(Path path) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public LinkedList<PcepValueType> createPcepLabelStack(DefaultLabelStack labelStack, Path path) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean allocateLocalLabel(Tunnel tunnel) {
+ // TODO Auto-generated method stub
+ return false;
+ }
}