Priyanka B
Committed by Priyankab-Huawei

[ONOS] Cherry picked from master 1.7

Change-Id: I74a0c1634f9c425af2bcb646edc3d9170b3c087c
Showing 73 changed files with 1948 additions and 84 deletions
......@@ -22,6 +22,7 @@
<groupId>org.onosproject</groupId>
<artifactId>onos-pce</artifactId>
<version>1.6.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>onos-app-pce</artifactId>
<packaging>bundle</packaging>
......
......@@ -19,7 +19,6 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
import static org.onosproject.net.Link.Type.DIRECT;
import java.util.Iterator;
......@@ -29,7 +28,6 @@ import java.util.LinkedList;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onlab.packet.IpAddress;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
......@@ -165,6 +163,7 @@ public class BasicPceccHandlerTest {
@After
public void tearDown() throws Exception {
PceManagerTest.flowsDownloaded = 0;
}
/**
......
......@@ -158,6 +158,7 @@ public class PceccSrTeBeHandlerTest {
@After
public void tearDown() throws Exception {
PceManagerTest.flowsDownloaded = 0;
}
/**
......

7.44 KB | W: | H:

23.3 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
......@@ -23,6 +23,7 @@
<groupId>org.onosproject</groupId>
<artifactId>onos-pce</artifactId>
<version>1.6.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>onos-app-pceweb</artifactId>
......@@ -42,6 +43,11 @@
<artifactId>onos-cli</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-pce</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<properties>
......
......@@ -63,7 +63,6 @@ public class PceWebTopovOverlay extends UiTopoOverlay {
public void modifyDeviceDetails(PropertyPanel pp, DeviceId deviceId) {
pp.title(MY_TITLE);
log.info("Modify device details called.");
DeviceService deviceService = AbstractShellCommand.get(DeviceService.class);
......
......@@ -34,7 +34,6 @@
glyphId: 'topo',
tooltip: 'PCE web Topo Overlay',
activate: function () {
$log.debug("PCE web topology overlay ACTIVATED");
},
......@@ -112,11 +111,32 @@
},
1: {
cb: function () {
pps.setMode("shortest");
pps.setMode();
},
tt: 'Setup path',
gid: 'plus'
},
2: {
cb: function () {
pps.updatePath(selection);
},
tt: 'Select constraints for LSP',
tt: 'Update path',
gid: '*jp'
},
3: {
cb: function () {
pps.remPath(selection);
},
tt: 'Remove path',
gid: 'minus'
},
4: {
cb: function () {
pps.queryTunnelDisplay();
},
tt: 'Show Tunnels',
gid: 'checkMark'
},
0: {
cb: function () {
pps.clear();
......@@ -126,7 +146,7 @@
},
_keyOrder: [
'openBracket', 'closeBracket', '1', '0'
'openBracket', 'closeBracket', '1', '2', '3', '4', '0'
]
},
hooks: {
......@@ -145,6 +165,9 @@
},
single: function (data) {
selectionCallback(data);
},
multi: function (selectOrder) {
selectionCallback(selectOrder);
}
}
};
......
......@@ -21,6 +21,7 @@
<groupId>org.onosproject</groupId>
<artifactId>onos-apps</artifactId>
<version>1.6.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -23,6 +23,7 @@
<groupId>org.onosproject</groupId>
<artifactId>onos-bgp</artifactId>
<version>1.6.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>onos-bgp-api</artifactId>
......
......@@ -23,6 +23,7 @@
<groupId>org.onosproject</groupId>
<artifactId>onos-bgp</artifactId>
<version>1.6.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>onos-bgpio</artifactId>
......
......@@ -241,12 +241,11 @@ public class BgpUpdateMsgVer4 implements BgpUpdateMsg {
afi = mpUnReach.afi();
safi = mpUnReach.safi();
}
}
if ((afi == Constants.AFI_FLOWSPEC_VALUE) && ((safi == Constants.SAFI_FLOWSPEC_VALUE)
|| (safi == Constants.VPN_SAFI_FLOWSPEC_VALUE))) {
//unfeasible route length
cb.writeShort(0);
}
if ((afi == Constants.AFI_FLOWSPEC_VALUE) || (afi == Constants.AFI_VALUE)) {
//unfeasible route length
cb.writeShort(0);
}
}
......
......@@ -171,15 +171,17 @@ public class As4Path implements BgpValueType {
if ((as4pathSet != null) && (as4pathSeq != null)) {
int iAsLenIndex = cb.writerIndex();
cb.writeByte(0);
cb.writeByte(AsPath.ASPATH_SEQ_TYPE);
cb.writeByte(as4pathSeq.size());
if (as4pathSeq.size() != 0) {
cb.writeByte(AsPath.ASPATH_SEQ_TYPE);
cb.writeByte(as4pathSeq.size());
for (int j = 0; j < as4pathSeq.size(); j++) {
cb.writeInt(as4pathSeq.get(j));
}
for (int j = 0; j < as4pathSeq.size(); j++) {
cb.writeInt(as4pathSeq.get(j));
}
int asLen = cb.writerIndex() - iAsLenIndex;
cb.setByte(iAsLenIndex, (byte) (asLen - 1));
int asLen = cb.writerIndex() - iAsLenIndex;
cb.setByte(iAsLenIndex, (byte) (asLen - 1));
}
} else {
cb.writeByte(0);
}
......
......@@ -208,15 +208,16 @@ public class AsPath implements BgpValueType {
if (isaspathSet()) {
int iAsLenIndex = cb.writerIndex();
cb.writeByte(0);
cb.writeByte(ASPATH_SEQ_TYPE);
cb.writeByte(aspathSeq.size());
if (aspathSeq.size() != 0) {
cb.writeByte(ASPATH_SEQ_TYPE);
cb.writeByte(aspathSeq.size());
for (int j = 0; j < aspathSeq.size(); j++) {
cb.writeShort(aspathSeq.get(j));
for (int j = 0; j < aspathSeq.size(); j++) {
cb.writeShort(aspathSeq.get(j));
}
int asLen = cb.writerIndex() - iAsLenIndex;
cb.setByte(iAsLenIndex, (byte) (asLen - 1));
}
int asLen = cb.writerIndex() - iAsLenIndex;
cb.setByte(iAsLenIndex, (byte) (asLen - 1));
} else {
cb.writeByte(0);
}
......
......@@ -106,7 +106,7 @@ public class LinkStateAttributes implements BgpValueType {
*
* @param linkStateAttribList Linked list of Link, Node and Prefix TLVs
*/
LinkStateAttributes(List<BgpValueType> linkStateAttribList) {
public LinkStateAttributes(List<BgpValueType> linkStateAttribList) {
this.linkStateAttribList = linkStateAttribList;
this.isLinkStateAttribute = true;
}
......
......@@ -163,7 +163,6 @@ public class WideCommunityAttrHeader implements BgpValueType {
c.writeShort(TYPE);
c.writeByte(flag);
c.writeByte(hopCount);
c.writeShort(length);
return c.writerIndex() - iLenStartIndex;
}
......
......@@ -97,8 +97,8 @@ public class WideCommunityIpV4Neighbour implements BgpValueType {
while (listIterator.hasNext()) {
IpV4Neighbour speaker = listIterator.next();
if (speaker instanceof IpV4Neighbour) {
c.writeInt(Integer.valueOf(speaker.localSpeaker.toString()));
c.writeInt(Integer.valueOf(speaker.remoteSpeaker.toString()));
c.writeBytes(speaker.localSpeaker().toOctets());
c.writeBytes(speaker.remoteSpeaker().toOctets());
}
}
......
......@@ -96,7 +96,7 @@ public final class BgpLinkAttrMaxLinkBandwidth implements BgpValueType {
*
* @return Maximum link bandwidth
*/
float linkAttrMaxLinkBandwidth() {
public float linkAttrMaxLinkBandwidth() {
return maxBandwidth;
}
......
......@@ -43,10 +43,10 @@ import java.util.Objects;
public class WideCommunity implements BgpValueType {
private static final Logger log = LoggerFactory.getLogger(WideCommunity.class);
public static final byte TYPE = (byte) 254; /* TODO: IANA Assigned */
public static final byte TYPE = (byte) 129;
public static final short LENGTH = 4;
public static final byte TYPE_LENGTH_SIZE = 3;
public static final byte FLAGS = (byte) 0x40;
public static final byte FLAGS = (byte) 0x90;
private WideCommunityAttrHeader wideCommunityHeader;
private int community;
private int localAsn;
......@@ -238,6 +238,9 @@ public class WideCommunity implements BgpValueType {
wideCommunityHeader.write(c);
int iComLengthIndex = c.writerIndex();
c.writeShort(0);
c.writeInt(community);
c.writeInt(localAsn);
c.writeInt(contextAsn);
......@@ -275,6 +278,9 @@ public class WideCommunity implements BgpValueType {
c.setShort(iTargetLenIndex, (short) (length - 2));
}
length = c.writerIndex() - iComLengthIndex;
c.setShort(iComLengthIndex, (short) (length - 2));
length = c.writerIndex() - iLengthIndex;
c.setShort(iLengthIndex, (short) (length - 2));
......
......@@ -46,6 +46,11 @@
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-common</artifactId>
<version>4.0.36.Final</version>
</dependency>
</dependencies>
<build>
......
......@@ -205,7 +205,7 @@ public class BgpConfig implements BgpCfg {
lspeer.setSelfInnitConnection(true);
if (lspeer.connectPeer() == null) {
connectPeer = new BgpConnectPeerImpl(bgpController, routerid, Controller.getBgpPortNum());
connectPeer = new BgpConnectPeerImpl(bgpController, routerid, Controller.BGP_PORT_NUM);
lspeer.setConnectPeer(connectPeer);
connectPeer.connectPeer();
}
......
......@@ -135,7 +135,7 @@ public class BgpLocalRibImpl implements BgpLocalRib {
BgpSelectionAlgo selectionAlgo = new BgpSelectionAlgo();
// Compare local RIB entry with the current attribute
decisionResult = selectionAlgo.compare(nodeTree.get(nodeLsIdentifier), detailsLocRib);
if (decisionResult < 0) {
if (decisionResult <= 0) {
for (BgpNodeListener l : bgpController.listener()) {
l.addNode((BgpNodeLSNlriVer4) nlri, details);
}
......@@ -155,7 +155,7 @@ public class BgpLocalRibImpl implements BgpLocalRib {
BgpSelectionAlgo selectionAlgo = new BgpSelectionAlgo();
// Compare local RIB entry with the current attribute
decisionResult = selectionAlgo.compare(linkTree.get(linkLsIdentifier), detailsLocRib);
if (decisionResult < 0) {
if (decisionResult <= 0) {
linkTree.replace(linkLsIdentifier, detailsLocRib);
for (BgpLinkListener l : bgpController.linkListener()) {
l.addLink((BgpLinkLsNlriVer4) nlri, details);
......@@ -175,7 +175,7 @@ public class BgpLocalRibImpl implements BgpLocalRib {
BgpSelectionAlgo selectionAlgo = new BgpSelectionAlgo();
// Compare local RIB entry with the current attribute
decisionResult = selectionAlgo.compare(prefixTree.get(prefixIdentifier), detailsLocRib);
if (decisionResult < 0) {
if (decisionResult <= 0) {
prefixTree.replace(prefixIdentifier, detailsLocRib);
log.debug("Local RIB update prefix: {}", detailsLocRib.toString());
}
......
......@@ -159,15 +159,16 @@ public class BgpPeerImpl implements BgpPeer {
* Send flow specification update message to peer.
*
* @param operType operation type
* @param routeKey flow rule key
* @param flowSpec flow specification details
* @param wideCommunity for route policy
* @param wideCommunity for route policy
*/
public final void sendFlowSpecUpdateMessageToPeer(FlowSpecOperation operType, BgpFlowSpecRouteKey routeKey,
BgpFlowSpecNlri flowSpec, WideCommunity wideCommunity) {
List<BgpValueType> attributesList = new LinkedList<>();
byte sessionType = sessionInfo.isIbgpSession() ? (byte) 0 : (byte) 1;
byte sAfi = Constants.VPN_SAFI_FLOWSPEC_VALUE;
byte sAfi = Constants.SAFI_FLOWSPEC_VALUE;
boolean isFsCapabilitySet = isCapabilitySupported(MultiProtocolExtnCapabilityTlv.TYPE,
Constants.AFI_FLOWSPEC_VALUE,
......@@ -190,10 +191,10 @@ public class BgpPeerImpl implements BgpPeer {
return;
}
if ((wideCommunity != null) && (isVpnRpdCapabilitySet)) {
sAfi = Constants.VPN_SAFI_FLOWSPEC_RDP_VALUE;
} else if (isVpnFsCapabilitySet) {
if (isVpnFsCapabilitySet) {
sAfi = Constants.VPN_SAFI_FLOWSPEC_VALUE;
} else if (isVpnRpdCapabilitySet) {
sAfi = Constants.VPN_SAFI_FLOWSPEC_RDP_VALUE;
}
attributesList.add(new Origin((byte) 0));
......@@ -222,7 +223,9 @@ public class BgpPeerImpl implements BgpPeer {
}
attributesList.add(new BgpExtendedCommunity(flowSpec.fsActionTlv()));
attributesList.add(wideCommunity);
if (wideCommunity != null) {
attributesList.add(wideCommunity);
}
if (operType == FlowSpecOperation.ADD) {
attributesList.add(new MpReachNlri(flowSpec, Constants.AFI_FLOWSPEC_VALUE, sAfi));
......
......@@ -16,7 +16,7 @@
package org.onosproject.bgp.controller.impl;
import static org.onlab.util.Tools.groupedThreads;
import io.netty.util.internal.PlatformDependent;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.net.InetSocketAddress;
......@@ -53,9 +53,11 @@ public class Controller {
public Channel serverChannel;
// Configuration options
private static final short BGP_PORT_NUM = 179;
protected static final short BGP_PORT_NUM = 179;
private static final short BGP_PRIVILEGED_PORT = 1790; // server port used for non root users in linux
private static final short PORT_NUM_ZERO = 0;
private static boolean isPortNumSet = false;
private static short portNumber = BGP_PORT_NUM;
private final int workerThreads = 16;
private final int peerWorkerThreads = 16;
......@@ -219,6 +221,11 @@ public class Controller {
*/
public void start() {
log.info("Started");
if (!PlatformDependent.isWindows() && !PlatformDependent.isRoot()) {
portNumber = BGP_PRIVILEGED_PORT;
} else {
portNumber = BGP_PORT_NUM;
}
this.init();
this.run();
}
......@@ -242,7 +249,8 @@ public class Controller {
if (isPortNumSet) {
return PORT_NUM_ZERO;
}
return BGP_PORT_NUM;
return portNumber;
}
/**
......
COMPILE_DEPS = [
'//lib:CORE_DEPS',
'//protocols/pcep/pcepio:onos-protocols-pcep-pcepio',
'//apps/pcep-api:onos-apps-pcep-api',
'//incubator/api:onos-incubator-api',
]
osgi_jar_with_tests (
......
......@@ -23,6 +23,7 @@
<groupId>org.onosproject</groupId>
<artifactId>onos-pcep-controller</artifactId>
<version>1.6.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>onos-pcep-controller-api</artifactId>
......@@ -51,5 +52,9 @@
<groupId>org.onosproject</groupId>
<artifactId>onlab-misc</artifactId>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-incubator-api</artifactId>
</dependency>
</dependencies>
</project>
......
......@@ -26,6 +26,8 @@ public class ClientCapability {
private boolean pceccCapability;
private boolean statefulPceCapability;
private boolean pcInstantiationCapability;
private boolean labelStackCapability;
private boolean srCapability;
/**
* Creates new instance of client capability.
......@@ -33,11 +35,34 @@ public class ClientCapability {
* @param pceccCapability represents PCECC capability
* @param statefulPceCapability represents stateful PCE capability
* @param pcInstantiationCapability represents PC initiation capability
* @param labelStackCapability represents S bit is set in PCECC capability
* @param srCapability represents SR capability
*/
public ClientCapability(boolean pceccCapability, boolean statefulPceCapability, boolean pcInstantiationCapability) {
public ClientCapability(boolean pceccCapability, boolean statefulPceCapability, boolean pcInstantiationCapability,
boolean labelStackCapability, boolean srCapability) {
this.pceccCapability = pceccCapability;
this.statefulPceCapability = statefulPceCapability;
this.pcInstantiationCapability = pcInstantiationCapability;
this.labelStackCapability = labelStackCapability;
this.srCapability = srCapability;
}
/**
* Obtains label stack capability.
*
* @return true if client supports PCECC capability with S bit set otherwise false
*/
public boolean labelStackCapability() {
return labelStackCapability;
}
/**
* Obtains segment routing capability.
*
* @return true if client supports SR capability otherwise false
*/
public boolean srCapability() {
return srCapability;
}
/**
......@@ -69,7 +94,8 @@ public class ClientCapability {
@Override
public int hashCode() {
return Objects.hash(pceccCapability, statefulPceCapability, pcInstantiationCapability);
return Objects.hash(pceccCapability, statefulPceCapability, pcInstantiationCapability, labelStackCapability,
srCapability);
}
@Override
......@@ -81,7 +107,9 @@ public class ClientCapability {
ClientCapability other = (ClientCapability) obj;
return Objects.equals(pceccCapability, other.pceccCapability)
&& Objects.equals(statefulPceCapability, other.statefulPceCapability)
&& Objects.equals(pcInstantiationCapability, other.pcInstantiationCapability);
&& Objects.equals(pcInstantiationCapability, other.pcInstantiationCapability)
&& Objects.equals(labelStackCapability, other.labelStackCapability)
&& Objects.equals(srCapability, other.srCapability);
}
return false;
}
......@@ -92,6 +120,8 @@ public class ClientCapability {
.add("pceccCapability", pceccCapability)
.add("statefulPceCapability", statefulPceCapability)
.add("pcInstantiationCapability", pcInstantiationCapability)
.add("labelStackCapability", labelStackCapability)
.add("srCapability", srCapability)
.toString();
}
}
\ No newline at end of file
......
/*
* 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.
*/
package org.onosproject.pcep.controller;
import java.util.Objects;
import com.google.common.base.MoreObjects;
/**
* Representation of LSP info, it will be unique for each LSP.
*/
public class LspKey {
private int plspId;
private short localLspId;
/**
* Creates new instance of LspInfo.
*
* @param plspId LSP id assigned per tunnel per session
* @param localLspId LSP id assigned per tunnel
*/
public LspKey(int plspId, short localLspId) {
this.plspId = plspId;
this.localLspId = localLspId;
}
/**
* Obtains PLSP id.
*
* @return LSP id assigned per tunnel per session
*/
public int plspId() {
return plspId;
}
/**
* Obtains local LSP id.
*
* @return LSP id assigned per tunnel
*/
public short localLspId() {
return localLspId;
}
@Override
public int hashCode() {
return Objects.hash(plspId, localLspId);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof LspKey) {
LspKey other = (LspKey) obj;
return Objects.equals(plspId, other.plspId)
&& Objects.equals(localLspId, other.localLspId);
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("plspId", plspId)
.add("localLspId", localLspId)
.toString();
}
}
\ No newline at end of file
......@@ -19,6 +19,7 @@ import java.util.List;
import org.onosproject.pcepio.protocol.PcepFactory;
import org.onosproject.pcepio.protocol.PcepMessage;
import org.onosproject.pcepio.protocol.PcepStateReport;
/**
* Represents to provider facing side of a path computation client(pcc).
......@@ -135,4 +136,64 @@ public interface PcepClient {
* @return capability supported by client
*/
ClientCapability capability();
/**
* Adds PCEP device when session is successfully established.
*
* @param pc PCEP client details
*/
void addNode(PcepClient pc);
/**
* Removes PCEP device when session is disconnected.
*
* @param pccId PCEP client ID
*/
void deleteNode(PccId pccId);
/**
* Sets D flag for the given LSP and its LSP info.
*
* @param lspKey contains LSP info
* @param dFlag delegation flag in LSP object
*/
void setLspAndDelegationInfo(LspKey lspKey, boolean dFlag);
/**
* Returns delegation flag for the given LSP info.
*
* @param lspKey contains LSP info
* @return delegation flag
*/
Boolean delegationInfo(LspKey lspKey);
/**
* Creates a temporary cache to hold report messages received during LSPDB sync.
*
* @param pccId PCC id which is the key to store report messages
*/
void initializeSyncMsgList(PccId pccId);
/**
* Returns the list of report messages received during LSPDB sync.
*
* @param pccId PCC id which is the key for all the report messages
* @return list of report messages received during LSPDB sync
*/
List<PcepStateReport> getSyncMsgList(PccId pccId);
/**
* Removes the list of report messages received during LSPDB sync.
*
* @param pccId PCC id which is the key for all the report messages
*/
void removeSyncMsgList(PccId pccId);
/**
* Adds report message received during LSPDB sync into temporary cache.
*
* @param pccId PCC id which is the key to store report messages
* @param rptMsg the report message to be stored
*/
void addSyncMsgToList(PccId pccId, PcepStateReport rptMsg);
}
......
......@@ -57,7 +57,7 @@ public interface PcepClientController {
void removeListener(PcepClientListener listener);
/**
* Register a listener for OF msg events.
* Register a listener for PCEP msg events.
*
* @param listener the listener to notify
*/
......@@ -71,6 +71,34 @@ public interface PcepClientController {
void removeEventListener(PcepEventListener listener);
/**
* Register a listener for PCEP msg events[carrying node descriptor details].
*
* @param listener the listener to notify
*/
void addNodeListener(PcepNodeListener listener);
/**
* Unregister a listener.
*
* @param listener the listener to be unregistered
*/
void removeNodeListener(PcepNodeListener listener);
/**
* Register a listener for packet events.
*
* @param listener the listener to notify
*/
void addPacketListener(PcepPacketListener listener);
/**
* Unregister a packet listener.
*
* @param listener the listener to unregister
*/
void removePacketListener(PcepPacketListener listener);
/**
* Send a message to a particular pcc client.
*
* @param pccId the id of the client to send message.
......
......@@ -15,6 +15,7 @@
*/
package org.onosproject.pcep.controller;
import org.onosproject.incubator.net.tunnel.Tunnel;
import org.onosproject.pcepio.protocol.PcepMessage;
/**
* Notifies providers about PCEP message events.
......@@ -28,4 +29,21 @@ public interface PcepEventListener {
* @param msg the message
*/
void handleMessage(PccId pccId, PcepMessage msg);
/**
* Handles end of LSPDB sync actions.
*
* @param tunnel the tunnel on which action needs to be taken
* @param endOfSyncAction the action that needs to be taken for the tunnel
*/
void handleEndOfSyncAction(Tunnel tunnel, PcepLspSyncAction endOfSyncAction);
/**
* Handles sending PCEP message to client on end of LSPDB sync.
*
* @param pccId id of the pcc
* @param msg the message to be sent
* @param endOfSyncAction the action that needs to be taken in the message
*/
void handleEndOfSyncAction(PccId pccId, PcepMessage msg, PcepLspSyncAction endOfSyncAction);
}
......
/*
* 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.
*/
package org.onosproject.pcep.controller;
/**
* Representation of actions to be taken for LSPs on end of LSP-DB sync.
*/
public enum PcepLspSyncAction {
/**
* Specifies that delete message for PCE intiiated tunnel should be sent.
*/
SEND_DELETE(0),
/**
* Specifies that update message should be sent.
*/
SEND_UPDATE(1),
/**
* Specifies that the tunnel should be removed from PCE.
*/
REMOVE(2),
/**
* Specifies that the status of the tunnel should be set as unstable.
*/
UNSTABLE(3);
int value;
/**
* Assigns val with the value for actions to be taken for LSPs on end of LSP-DB sync.
*
* @param val sync status
*/
PcepLspSyncAction(int val) {
value = val;
}
}
/*
* 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.
*/
package org.onosproject.pcep.controller;
/**
* Notifies providers about PCEP node events.
*/
public interface PcepNodeListener {
/**
* Notifies that the node was added.
*
* @param pc PCEP client details
*/
void addNode(PcepClient pc);
/**
* Notifies that the node was removed.
*
* @param pccId PCEP client ID
*/
void deleteNode(PccId pccId);
}
/*
* 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.
*/
package org.onosproject.pcep.controller;
public interface PcepPacketListener {
void sendPacketIn(PccId pccId);
}
......@@ -60,4 +60,25 @@ public interface PcepAgent {
*/
void processPcepMessage(PccId pccId, PcepMessage m);
/**
* Adds PCEP device when session is successfully established.
*
* @param pc PCEP client details
*/
void addNode(PcepClient pc);
/**
* Removes PCEP device when session is disconnected.
*
* @param pccId PCEP client ID
*/
void deleteNode(PccId pccId);
/**
* Analyzes report messages received during LSP DB sync again tunnel store and takes necessary actions.
*
* @param pccId the id of pcc client
* @return success or failure
*/
boolean analyzeSyncMsgList(PccId pccId);
}
......
......@@ -2,6 +2,7 @@ COMPILE_DEPS = [
'//lib:CORE_DEPS',
'//protocols/pcep/pcepio:onos-protocols-pcep-pcepio',
'//protocols/pcep/api:onos-protocols-pcep-api',
'//incubator/api:onos-incubator-api',
]
osgi_jar_with_tests (
......
......@@ -55,6 +55,7 @@ import org.onosproject.pcepio.protocol.PcepVersion;
import org.onosproject.pcepio.types.IPv4RouterIdOfLocalNodeSubTlv;
import org.onosproject.pcepio.types.NodeAttributesTlv;
import org.onosproject.pcepio.types.PceccCapabilityTlv;
import org.onosproject.pcepio.types.SrPceCapabilityTlv;
import org.onosproject.pcepio.types.StatefulPceCapabilityTlv;
import org.onosproject.pcepio.types.PcepErrorDetailInfo;
import org.onosproject.pcepio.types.PcepValueType;
......@@ -260,6 +261,8 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler {
disconnectDuplicate(h);
} else {
h.setState(ESTABLISHED);
//Session is established, add a PCEP device
h.addNode();
}
}
}
......@@ -469,6 +472,20 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler {
}
/**
* Adds PCEP device once session is established.
*/
private void addNode() {
pc.addNode(pc);
}
/**
* Deletes PCEP device when session is disconnected.
*/
private void deleteNode() {
pc.deleteNode(pc.getPccId());
}
/**
* Return a string describing this client based on the already available
* information (ip address and/or remote socket).
*
......@@ -523,6 +540,8 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler {
boolean pceccCapability = false;
boolean statefulPceCapability = false;
boolean pcInstantiationCapability = false;
boolean labelStackCapability = false;
boolean srCapability = false;
ListIterator<PcepValueType> listIterator = tlvList.listIterator();
while (listIterator.hasNext()) {
......@@ -531,6 +550,9 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler {
switch (tlv.getType()) {
case PceccCapabilityTlv.TYPE:
pceccCapability = true;
if (((PceccCapabilityTlv) tlv).sBit()) {
labelStackCapability = true;
}
break;
case StatefulPceCapabilityTlv.TYPE:
statefulPceCapability = true;
......@@ -539,11 +561,15 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler {
pcInstantiationCapability = true;
}
break;
case SrPceCapabilityTlv.TYPE:
srCapability = true;
break;
default:
continue;
}
}
this.capability = new ClientCapability(pceccCapability, statefulPceCapability, pcInstantiationCapability);
this.capability = new ClientCapability(pceccCapability, statefulPceCapability, pcInstantiationCapability,
labelStackCapability, srCapability);
}
/**
......@@ -563,6 +589,8 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler {
*/
private void sendErrMsgAndCloseChannel() {
// TODO send error message
//Remove PCEP device from topology
deleteNode();
channel.close();
}
......
......@@ -19,13 +19,18 @@ package org.onosproject.pcep.controller.impl;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.RejectedExecutionException;
import org.jboss.netty.channel.Channel;
import org.onlab.packet.IpAddress;
import org.onosproject.pcep.controller.ClientCapability;
import org.onosproject.pcep.controller.LspKey;
import org.onosproject.pcep.controller.PccId;
import org.onosproject.pcep.controller.PcepClient;
import org.onosproject.pcep.controller.PcepPacketStats;
import org.onosproject.pcep.controller.PcepSyncStatus;
import org.onosproject.pcep.controller.driver.PcepAgent;
......@@ -33,6 +38,7 @@ import org.onosproject.pcep.controller.driver.PcepClientDriver;
import org.onosproject.pcepio.protocol.PcepFactories;
import org.onosproject.pcepio.protocol.PcepFactory;
import org.onosproject.pcepio.protocol.PcepMessage;
import org.onosproject.pcepio.protocol.PcepStateReport;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -66,6 +72,8 @@ public class PcepClientImpl implements PcepClientDriver {
private byte deadTime;
private byte sessionId;
private PcepPacketStatsImpl pktStats;
private Map<LspKey, Boolean> lspDelegationInfo;
private Map<PccId, List<PcepStateReport>> sycRptCache = new HashMap<>();
@Override
public void init(PccId pccId, PcepVersion pcepVersion, PcepPacketStats pktStats) {
......@@ -188,7 +196,14 @@ public class PcepClientImpl implements PcepClientDriver {
@Override
public void setLabelDbSyncStatus(PcepSyncStatus syncStatus) {
PcepSyncStatus syncOldStatus = labelDbSyncStatus();
this.labelDbSyncStatus = syncStatus;
if ((syncOldStatus == PcepSyncStatus.IN_SYNC) && (syncStatus == PcepSyncStatus.SYNCED)) {
// Perform end of LSP DB sync actions.
this.agent.analyzeSyncMsgList(pccId);
}
}
@Override
......@@ -203,6 +218,16 @@ public class PcepClientImpl implements PcepClientDriver {
}
@Override
public void addNode(PcepClient pc) {
this.agent.addNode(pc);
}
@Override
public void deleteNode(PccId pccId) {
this.agent.deleteNode(pccId);
}
@Override
public final boolean connectClient() {
return this.agent.addConnectedClient(pccId, this);
}
......@@ -230,6 +255,39 @@ public class PcepClientImpl implements PcepClientDriver {
}
@Override
public void setLspAndDelegationInfo(LspKey lspKey, boolean dFlag) {
lspDelegationInfo.put(lspKey, dFlag);
}
@Override
public Boolean delegationInfo(LspKey lspKey) {
return lspDelegationInfo.get(lspKey);
}
@Override
public void initializeSyncMsgList(PccId pccId) {
List<PcepStateReport> rptMsgList = new LinkedList<>();
sycRptCache.put(pccId, rptMsgList);
}
@Override
public List<PcepStateReport> getSyncMsgList(PccId pccId) {
return sycRptCache.get(pccId);
}
@Override
public void removeSyncMsgList(PccId pccId) {
sycRptCache.remove(pccId);
}
@Override
public void addSyncMsgToList(PccId pccId, PcepStateReport rptMsg) {
List<PcepStateReport> rptMsgList = sycRptCache.get(pccId);
rptMsgList.add(rptMsg);
sycRptCache.put(pccId, rptMsgList);
}
@Override
public boolean isOptical() {
return false;
}
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.provider.pcep.tunnel.impl;
package org.onosproject.pcep.controller.impl;
import org.onosproject.incubator.net.tunnel.Tunnel.State;
......@@ -51,6 +51,7 @@ public enum PcepLspStatus {
* Returns the applicable PCEP LSP status corresponding to ONOS tunnel state.
*
* @param tunnelState ONOS tunnel state
* @return LSP status as per protocol
*/
public static PcepLspStatus getLspStatusFromTunnelStatus(State tunnelState) {
......@@ -76,6 +77,7 @@ public enum PcepLspStatus {
* Returns the applicable ONOS tunnel state corresponding to PCEP LSP status.
*
* @param lspState PCEP LSP status
* @return tunnel state
*/
public static State getTunnelStatusFromLspStatus(PcepLspStatus lspState) {
......
......@@ -29,14 +29,14 @@ public interface PcepBandwidthObject {
*
* @return bandwidth value
*/
int getBandwidth();
float getBandwidth();
/**
* Sets bandwidth with specified value.
*
* @param iBandwidth Bandwidth's value
*/
void setBandwidth(int iBandwidth);
void setBandwidth(float iBandwidth);
/**
* Writes the BandwidthObject into channel buffer.
......
......@@ -51,6 +51,7 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject {
public static final byte BANDWIDTH_OBJ_TYPE = 1;
public static final byte BANDWIDTH_OBJ_CLASS = 5;
public static final byte BANDWIDTH_OBJECT_VERSION = 1;
public static final int NO_OF_BITS = 8;
public static final short BANDWIDTH_OBJ_MINIMUM_LENGTH = 8;
static final PcepObjectHeader DEFAULT_BANDWIDTH_OBJECT_HEADER = new PcepObjectHeader(BANDWIDTH_OBJ_CLASS,
......@@ -58,7 +59,7 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject {
BANDWIDTH_OBJ_MINIMUM_LENGTH);
private PcepObjectHeader bandwidthObjHeader;
private int iBandwidth;
private float iBandwidth;
/**
* Constructor to bandwidth object header and bandwidth.
......@@ -66,7 +67,7 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject {
* @param bandwidthObjHeader bandwidth object header
* @param iBandwidth bandwidth value
*/
public PcepBandwidthObjectVer1(PcepObjectHeader bandwidthObjHeader, int iBandwidth) {
public PcepBandwidthObjectVer1(PcepObjectHeader bandwidthObjHeader, float iBandwidth) {
this.bandwidthObjHeader = bandwidthObjHeader;
this.iBandwidth = iBandwidth;
}
......@@ -76,7 +77,7 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject {
*
* @param iBandwidth bandwidth value
*/
public PcepBandwidthObjectVer1(int iBandwidth) {
public PcepBandwidthObjectVer1(float iBandwidth) {
this.bandwidthObjHeader = DEFAULT_BANDWIDTH_OBJECT_HEADER;
this.iBandwidth = iBandwidth;
}
......@@ -100,12 +101,12 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject {
}
@Override
public int getBandwidth() {
public float getBandwidth() {
return this.iBandwidth;
}
@Override
public void setBandwidth(int iBandwidth) {
public void setBandwidth(float iBandwidth) {
this.iBandwidth = iBandwidth;
}
......@@ -119,12 +120,25 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject {
public static PcepBandwidthObject read(ChannelBuffer cb) throws PcepParseException {
PcepObjectHeader bandwidthObjHeader;
int iBandwidth;
float bandwidth;
bandwidthObjHeader = PcepObjectHeader.read(cb);
iBandwidth = cb.readInt();
bandwidth = ieeeToFloatRead(cb.readInt()) * NO_OF_BITS;
return new PcepBandwidthObjectVer1(bandwidthObjHeader, iBandwidth);
return new PcepBandwidthObjectVer1(bandwidthObjHeader, bandwidth);
}
/**
* Parse the IEEE floating point notation and returns it in normal float.
*
* @param iVal IEEE floating point number
* @return normal float
*/
public static float ieeeToFloatRead(int iVal) {
iVal = (((iVal & 0xFF) << 24) | ((iVal & 0xFF00) << 8)
| ((iVal & 0xFF0000) >> 8) | ((iVal >> 24) & 0xFF));
return Float.intBitsToFloat(iVal);
}
@Override
......@@ -138,7 +152,7 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject {
throw new PcepParseException("Failed to write bandwidth object header. Index " + objLenIndex);
}
cb.writeInt(iBandwidth);
cb.writeInt(Float.floatToIntBits(iBandwidth));
short hLength = (short) (cb.writerIndex() - objStartIndex);
cb.setShort(objLenIndex, hLength);
//will be helpful during print().
......
......@@ -16,8 +16,10 @@
package org.onosproject.pcepio.protocol.ver1;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.exceptions.PcepParseException;
......@@ -399,10 +401,47 @@ public class PcepEroObjectVer1 implements PcepEroObject {
}
@Override
public int hashCode() {
return Objects.hash(eroObjHeader, subObjectList);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass()).omitNullValues()
.add("EroObjHeader", eroObjHeader)
.add("SubObjects", subObjectList)
.toString();
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof PcepEroObjectVer1) {
int countObjSubTlv = 0;
int countOtherSubTlv = 0;
boolean isCommonSubTlv = true;
PcepEroObjectVer1 other = (PcepEroObjectVer1) obj;
Iterator<PcepValueType> objListIterator = other.subObjectList.iterator();
countOtherSubTlv = other.subObjectList.size();
countObjSubTlv = subObjectList.size();
if (countObjSubTlv != countOtherSubTlv) {
return false;
} else {
while (objListIterator.hasNext() && isCommonSubTlv) {
PcepValueType subTlv = objListIterator.next();
if (subObjectList.contains(subTlv)) {
isCommonSubTlv = Objects.equals(subObjectList.get(subObjectList.indexOf(subTlv)),
other.subObjectList.get(other.subObjectList.indexOf(subTlv)));
} else {
isCommonSubTlv = false;
}
}
return isCommonSubTlv && Objects.equals(eroObjHeader, other.eroObjHeader);
}
}
return false;
}
}
......
......@@ -57,6 +57,10 @@ public class PcepMetricObjectVer1 implements PcepMetricObject {
public static final int BFLAG_RESET = 0;
public static final byte CFLAG_CHECK = 0x02;
public static final byte IGP_METRIC = 0x01;
public static final byte TE_METRIC = 0x02;
public static final byte HOP_COUNT_METRIC = 0x03;
static final PcepObjectHeader DEFAULT_METRIC_OBJECT_HEADER = new PcepObjectHeader(METRIC_OBJ_CLASS,
METRIC_OBJ_TYPE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED,
METRIC_OBJ_MINIMUM_LENGTH);
......
......@@ -16,6 +16,8 @@
package org.onosproject.pcepio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -212,6 +214,27 @@ public class PcepObjectHeader {
}
@Override
public int hashCode() {
return Objects.hash(objClass, objType, bPFlag, bIFlag, objLen);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof PcepObjectHeader) {
PcepObjectHeader other = (PcepObjectHeader) obj;
return Objects.equals(objClass, other.objClass)
&& Objects.equals(objType, other.objType)
&& Objects.equals(bPFlag, other.bPFlag)
&& Objects.equals(bIFlag, other.bIFlag)
&& Objects.equals(objLen, other.objLen);
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("ObjectClass", objClass)
......
......@@ -40,6 +40,11 @@
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-incubator-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-api</artifactId>
<classifier>tests</classifier>
<scope>test</scope>
......
......@@ -3,6 +3,7 @@ COMPILE_DEPS = [
'//protocols/bgp/api:onos-protocols-bgp-api',
'//protocols/bgp/bgpio:onos-protocols-bgp-bgpio',
'//incubator/store:onos-incubator-store',
'//incubator/api:onos-incubator-api',
]
TEST_DEPS = [
......
<!--
~ 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.6.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>
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.TCP;
import org.onosproject.net.AnnotationKeys;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.Device;
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.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 = null;
// Find PCC deviceID from lsrId stored as annotations
Iterable<Device> devices = deviceService.getAvailableDevices();
for (Device dev : devices) {
if ("L3".equals(dev.annotations().value(AnnotationKeys.TYPE))
&& lsrId.equals(dev.annotations().value(LSRID))) {
pccDeviceId = dev.id();
break;
}
}
if (pccDeviceId == null) {
return;
}
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.
return;
}
}
@Override
public void emit(OutboundPacket packet) {
// Nothing to emit
return;
}
}
/*
* 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
......@@ -27,5 +27,6 @@
<module>topology</module>
<module>tunnel</module>
<module>app</module>
<module>packet</module>
</modules>
</project>
\ No newline at end of file
......
......@@ -3,6 +3,9 @@ COMPILE_DEPS = [
'//protocols/ovsdb/api:onos-protocols-ovsdb-api',
'//protocols/ovsdb/rfc:onos-protocols-ovsdb-rfc',
'//apps/pcep-api:onos-apps-pcep-api',
'//protocols/pcep/api:onos-protocols-pcep-api',
'//protocols/pcep/pcepio:onos-protocols-pcep-pcepio',
'//core/api:onos-api-tests',
]
osgi_jar_with_tests (
......
......@@ -23,10 +23,20 @@
<artifactId>onos-pcep-provider-topology</artifactId>
<packaging>bundle</packaging>
<description>PCEP topology provider</description>
<dependencies>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-pcep-api</artifactId>
</dependency>
</dependencies>
<dependencies>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-pcep-api</artifactId>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-pcep-controller-api</artifactId>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-api</artifactId>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......
......@@ -62,6 +62,10 @@ import org.onosproject.pcep.api.PcepLinkListener;
import org.onosproject.pcep.api.PcepOperator.OperationType;
import org.onosproject.pcep.api.PcepSwitch;
import org.onosproject.pcep.api.PcepSwitchListener;
import org.onosproject.pcep.controller.PccId;
import org.onosproject.pcep.controller.PcepClient;
import org.onosproject.pcep.controller.PcepClientController;
import org.onosproject.pcep.controller.PcepNodeListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -115,18 +119,40 @@ public class PcepTopologyProvider extends AbstractProvider
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected ClusterService clusterService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected PcepClientController pcepClientController;
private DeviceProviderService deviceProviderService;
private LinkProviderService linkProviderService;
private HashMap<Long, List<PortDescription>> portMap = new HashMap<>();
private InternalLinkProvider listener = new InternalLinkProvider();
/*
* For the client supporting SR capability.
*/
public static final String SR_CAPABILITY = "srCapability";
/*
* For the client supporting PCECC capability.
*/
public static final String PCECC_CAPABILITY = "pceccCapability";
/*
* For the client supporting label stack capability.
*/
public static final String LABEL_STACK_CAPABILITY = "labelStackCapability";
public static final String LSRID = "lsrId";
private static final String UNKNOWN = "unknown";
@Activate
public void activate() {
linkProviderService = linkProviderRegistry.register(this);
deviceProviderService = deviceProviderRegistry.register(this);
controller.addListener(listener);
controller.addLinkListener(listener);
pcepClientController.addNodeListener(listener);
}
@Deactivate
......@@ -135,6 +161,7 @@ public class PcepTopologyProvider extends AbstractProvider
linkProviderService = null;
controller.removeListener(listener);
controller.removeLinkListener(listener);
pcepClientController.removeNodeListener(listener);
}
private List<PortDescription> buildPortDescriptions(PcepDpid dpid,
......@@ -225,7 +252,7 @@ public class PcepTopologyProvider extends AbstractProvider
}
private class InternalLinkProvider
implements PcepSwitchListener, PcepLinkListener {
implements PcepSwitchListener, PcepLinkListener, PcepNodeListener {
@Override
public void switchAdded(PcepDpid dpid) {
......@@ -306,6 +333,51 @@ public class PcepTopologyProvider extends AbstractProvider
}
}
@Override
public void addNode(PcepClient pc) {
if (deviceProviderService == null) {
return;
}
//Right now device URI for PCEP devices is their LSRID
DeviceId deviceId = deviceId(uri(new PcepDpid(pc.getPccId().id().getIp4Address().toInt())));
ChassisId cId = new ChassisId();
Device.Type deviceType = Device.Type.ROUTER;
DefaultAnnotations.Builder annotationBuilder = DefaultAnnotations.builder();
//PCC capabilities (SR, PCECC and PCECC-SR)
annotationBuilder.set(SR_CAPABILITY, String.valueOf(pc.capability().srCapability()));
annotationBuilder.set(PCECC_CAPABILITY, String.valueOf(pc.capability().pceccCapability()));
annotationBuilder.set(LABEL_STACK_CAPABILITY, String.valueOf(pc.capability().labelStackCapability()));
//PccId is the lsrId contained in openMsg, if not present it will be the socket address
annotationBuilder.set(LSRID, String.valueOf(pc.getPccId().id()));
DeviceDescription description = new DefaultDeviceDescription(
deviceId.uri(),
deviceType,
UNKNOWN,
UNKNOWN,
UNKNOWN,
UNKNOWN,
cId,
annotationBuilder.build());
deviceProviderService.deviceConnected(deviceId, description);
}
@Override
public void deleteNode(PccId pccId) {
if (deviceProviderService == null || deviceService == null) {
return;
}
//TODO: In device manager, in deviceDisconnected() method, get the device but null check is not validated
if (deviceService.getDevice(DeviceId.deviceId(uri(new PcepDpid(pccId.id()
.getIp4Address().toInt())))) == null) {
return;
}
deviceProviderService.deviceDisconnected(deviceId(uri(new PcepDpid(pccId.id().getIp4Address().toInt()))));
}
}
@Override
......
/*
* 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.
*/
package org.onosproject.provider.pcep.topology.impl;
import static org.junit.Assert.assertNotNull;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.RejectedExecutionException;
import org.jboss.netty.channel.Channel;
import org.onosproject.pcep.controller.ClientCapability;
import org.onosproject.pcep.controller.PccId;
import org.onosproject.pcep.controller.LspKey;
import org.onosproject.pcep.controller.PcepClient;
import org.onosproject.pcep.controller.PcepSyncStatus;
import org.onosproject.pcepio.protocol.PcepFactories;
import org.onosproject.pcepio.protocol.PcepFactory;
import org.onosproject.pcepio.protocol.PcepMessage;
import org.onosproject.pcepio.protocol.PcepStateReport;
import org.onosproject.pcepio.protocol.PcepVersion;
/**
* Representation of PCEP client adapter.
*/
public class PcepClientAdapter implements PcepClient {
private Channel channel;
protected String channelId;
private boolean connected;
private PccId pccId;
private ClientCapability capability;
private PcepVersion pcepVersion;
private PcepSyncStatus lspDbSyncStatus;
private PcepSyncStatus labelDbSyncStatus;
private Map<LspKey, Boolean> lspDelegationInfo = new HashMap<>();
/**
* Initialize instance with specified parameters.
*
* @param pccId PCC id
* @param pcepVersion PCEP message version
*/
public void init(PccId pccId, PcepVersion pcepVersion) {
this.pccId = pccId;
this.pcepVersion = pcepVersion;
}
@Override
public final void disconnectClient() {
this.channel.close();
}
@Override
public final void sendMessage(PcepMessage m) {
}
@Override
public final void sendMessage(List<PcepMessage> msgs) {
try {
PcepMessage pcepMsg = msgs.get(0);
assertNotNull("PCEP MSG should be created.", pcepMsg);
} catch (RejectedExecutionException e) {
throw e;
}
}
@Override
public final boolean isConnected() {
return this.connected;
}
@Override
public String channelId() {
return channelId;
}
@Override
public final PccId getPccId() {
return this.pccId;
};
@Override
public final String getStringId() {
return this.pccId.toString();
}
@Override
public final void handleMessage(PcepMessage m) {
}
@Override
public boolean isOptical() {
return false;
}
@Override
public PcepFactory factory() {
return PcepFactories.getFactory(pcepVersion);
}
@Override
public void setLspDbSyncStatus(PcepSyncStatus syncStatus) {
this.lspDbSyncStatus = syncStatus;
}
@Override
public PcepSyncStatus lspDbSyncStatus() {
return lspDbSyncStatus;
}
@Override
public void setLabelDbSyncStatus(PcepSyncStatus syncStatus) {
this.labelDbSyncStatus = syncStatus;
}
@Override
public PcepSyncStatus labelDbSyncStatus() {
return labelDbSyncStatus;
}
@Override
public void setCapability(ClientCapability capability) {
this.capability = capability;
}
@Override
public ClientCapability capability() {
return capability;
}
@Override
public void addNode(PcepClient pc) {
}
@Override
public void deleteNode(PccId pccId) {
}
@Override
public void setLspAndDelegationInfo(LspKey lspKey, boolean dFlag) {
lspDelegationInfo.put(lspKey, dFlag);
}
@Override
public Boolean delegationInfo(LspKey lspKey) {
return lspDelegationInfo.get(lspKey);
}
@Override
public void initializeSyncMsgList(PccId pccId) {
// TODO Auto-generated method stub
}
@Override
public List<PcepStateReport> getSyncMsgList(PccId pccId) {
// TODO Auto-generated method stub
return null;
}
@Override
public void removeSyncMsgList(PccId pccId) {
// TODO Auto-generated method stub
}
@Override
public void addSyncMsgToList(PccId pccId, PcepStateReport rptMsg) {
// TODO Auto-generated method stub
}
}
/*
* 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.
*/
package org.onosproject.provider.pcep.topology.impl;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Deactivate;
import org.onlab.packet.IpAddress;
import org.onosproject.pcep.controller.ClientCapability;
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;
import org.onosproject.pcepio.protocol.PcepErrorMsg;
import org.onosproject.pcepio.protocol.PcepErrorObject;
import org.onosproject.pcepio.protocol.PcepFactory;
import org.onosproject.pcepio.protocol.PcepMessage;
import org.onosproject.pcepio.protocol.PcepVersion;
import com.google.common.collect.Sets;
import static org.onosproject.pcepio.types.PcepErrorDetailInfo.ERROR_TYPE_19;
import static org.onosproject.pcepio.types.PcepErrorDetailInfo.ERROR_VALUE_5;
/**
* Representation of PCEP client controller adapter.
*/
public class PcepClientControllerAdapter implements PcepClientController {
protected ConcurrentHashMap<PccId, PcepClient> connectedClients =
new ConcurrentHashMap<PccId, PcepClient>();
protected PcepClientAgent agent = new PcepClientAgent();
protected Set<PcepClientListener> pcepClientListener = new HashSet<>();
protected Set<PcepEventListener> pcepEventListener = Sets.newHashSet();
public Set<PcepNodeListener> pcepNodeListener = Sets.newHashSet();
@Activate
public void activate() {
}
@Deactivate
public void deactivate() {
}
@Override
public Collection<PcepClient> getClients() {
return connectedClients.values();
}
@Override
public PcepClient getClient(PccId pccId) {
if (null != connectedClients.get(pccId)) {
return connectedClients.get(pccId);
}
PcepClientAdapter pc = new PcepClientAdapter();
if (pccId.ipAddress().equals(IpAddress.valueOf(0xC010103))
|| pccId.ipAddress().equals(IpAddress.valueOf(0xB6024E22))) {
pc.setCapability(new ClientCapability(true, false, false, false, false));
} else {
pc.setCapability(new ClientCapability(true, true, true, false, false));
}
pc.init(PccId.pccId(pccId.ipAddress()), PcepVersion.PCEP_1);
connectedClients.put(pccId, pc);
return pc;
}
@Override
public void addListener(PcepClientListener listener) {
if (!pcepClientListener.contains(listener)) {
this.pcepClientListener.add(listener);
}
}
@Override
public void addNodeListener(PcepNodeListener listener) {
pcepNodeListener.add(listener);
}
@Override
public void removeNodeListener(PcepNodeListener listener) {
pcepNodeListener.remove(listener);
}
@Override
public void removeListener(PcepClientListener listener) {
this.pcepClientListener.remove(listener);
}
@Override
public void addEventListener(PcepEventListener listener) {
pcepEventListener.add(listener);
}
@Override
public void removeEventListener(PcepEventListener listener) {
pcepEventListener.remove(listener);
}
@Override
public void writeMessage(PccId pccId, PcepMessage msg) {
this.getClient(pccId).sendMessage(msg);
}
@Override
public void processClientMessage(PccId pccId, PcepMessage msg) {
PcepClient pc = getClient(pccId);
switch (msg.getType()) {
case NONE:
break;
case OPEN:
break;
case KEEP_ALIVE:
//log.debug("Sending Keep Alive Message to {" + pccIpAddress.toString() + "}");
pc.sendMessage(Collections.singletonList(pc.factory().buildKeepaliveMsg().build()));
break;
case PATH_COMPUTATION_REQUEST:
break;
case PATH_COMPUTATION_REPLY:
break;
case NOTIFICATION:
break;
case ERROR:
break;
case CLOSE:
//log.debug("Sending Close Message to { }", pccIpAddress.toString());
pc.sendMessage(Collections.singletonList(pc.factory().buildCloseMsg().build()));
break;
case INITIATE:
if (!pc.capability().pcInstantiationCapability()) {
pc.sendMessage(Collections.singletonList(getErrMsg(pc.factory(),
ERROR_TYPE_19, ERROR_VALUE_5)));
}
break;
case REPORT:
//Only update the listener if respective capability is supported else send PCEP-ERR msg
if (pc.capability().statefulPceCapability()) {
for (PcepEventListener l : pcepEventListener) {
l.handleMessage(pccId, msg);
}
} else {
// Send PCEP-ERROR message.
pc.sendMessage(Collections.singletonList(getErrMsg(pc.factory(),
ERROR_TYPE_19, ERROR_VALUE_5)));
}
break;
case UPDATE:
if (!pc.capability().statefulPceCapability()) {
pc.sendMessage(Collections.singletonList(getErrMsg(pc.factory(),
ERROR_TYPE_19, ERROR_VALUE_5)));
}
break;
case LABEL_UPDATE:
if (!pc.capability().pceccCapability()) {
pc.sendMessage(Collections.singletonList(getErrMsg(pc.factory(),
ERROR_TYPE_19, ERROR_VALUE_5)));
}
break;
case MAX:
break;
case END:
break;
default:
break;
}
}
@Override
public void closeConnectedClients() {
PcepClient pc;
for (PccId id : connectedClients.keySet()) {
pc = getClient(id);
pc.disconnectClient();
}
}
private PcepErrorMsg getErrMsg(PcepFactory factory, byte errorType, byte errorValue) {
LinkedList<PcepError> llPcepErr = new LinkedList<>();
LinkedList<PcepErrorObject> llerrObj = new LinkedList<>();
PcepErrorMsg errMsg;
PcepErrorObject errObj = factory.buildPcepErrorObject().setErrorValue(errorValue).setErrorType(errorType)
.build();
llerrObj.add(errObj);
PcepError pcepErr = factory.buildPcepError().setErrorObjList(llerrObj).build();
llPcepErr.add(pcepErr);
PcepErrorInfo errInfo = factory.buildPcepErrorInfo().setPcepErrorList(llPcepErr).build();
errMsg = factory.buildPcepErrorMsg().setPcepErrorInfo(errInfo).build();
return errMsg;
}
/**
* Implementation of an Pcep Agent which is responsible for
* keeping track of connected clients and the state in which
* they are.
*/
public class PcepClientAgent implements PcepAgent {
@Override
public boolean addConnectedClient(PccId pccId, PcepClient pc) {
if (connectedClients.get(pccId) != null) {
return false;
} else {
connectedClients.put(pccId, pc);
for (PcepClientListener l : pcepClientListener) {
l.clientConnected(pccId);
}
return true;
}
}
@Override
public boolean validActivation(PccId pccId) {
if (connectedClients.get(pccId) == null) {
//log.error("Trying to activate client but is not in "
// + "connected switches: pccIp {}. Aborting ..", pccIpAddress.toString());
return false;
}
return true;
}
@Override
public void removeConnectedClient(PccId pccId) {
connectedClients.remove(pccId);
for (PcepClientListener l : pcepClientListener) {
//log.warn("removal for {}", pccIpAddress.toString());
l.clientDisconnected(pccId);
}
}
@Override
public void processPcepMessage(PccId pccId, PcepMessage m) {
processClientMessage(pccId, m);
}
@Override
public void addNode(PcepClient pc) {
for (PcepNodeListener l : pcepNodeListener) {
l.addNode(pc);
}
}
@Override
public void deleteNode(PccId pccId) {
for (PcepNodeListener l : pcepNodeListener) {
l.deleteNode(pccId);
}
}
@Override
public boolean analyzeSyncMsgList(PccId pccId) {
// TODO Auto-generated method stub
return false;
}
}
@Override
public void addPacketListener(PcepPacketListener listener) {
// TODO Auto-generated method stub
}
@Override
public void removePacketListener(PcepPacketListener listener) {
// TODO Auto-generated method stub
}
}
/*
* 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.
*/
package org.onosproject.provider.pcep.topology.impl;
import org.onosproject.net.DeviceId;
import org.onosproject.pcep.api.PcepController;
import org.onosproject.pcep.api.PcepDpid;
import org.onosproject.pcep.api.PcepLinkListener;
import org.onosproject.pcep.api.PcepSwitch;
import org.onosproject.pcep.api.PcepSwitchListener;
import org.onosproject.pcep.api.PcepTunnel;
import org.onosproject.pcep.api.PcepTunnelListener;
/**
* Implementation of PCEP controller.
*/
public class PcepControllerAdapter implements PcepController {
@Override
public Iterable<PcepSwitch> getSwitches() {
return null;
}
@Override
public PcepSwitch getSwitch(PcepDpid did) {
return null;
}
@Override
public void addListener(PcepSwitchListener listener) {
}
@Override
public void removeListener(PcepSwitchListener listener) {
}
@Override
public void addLinkListener(PcepLinkListener listener) {
}
@Override
public void removeLinkListener(PcepLinkListener listener) {
}
@Override
public void addTunnelListener(PcepTunnelListener listener) {
}
@Override
public void removeTunnelListener(PcepTunnelListener listener) {
}
@Override
public PcepTunnel applyTunnel(DeviceId srcDid, DeviceId dstDid, long srcPort, long dstPort, long bandwidth,
String name) {
return null;
}
@Override
public Boolean deleteTunnel(String id) {
return null;
}
@Override
public Boolean updateTunnelBandwidth(String id, long bandwidth) {
return null;
}
@Override
public void getTunnelStatistics(String pcepTunnelId) {
}
}
/*
* 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.
*/
package org.onosproject.provider.pcep.topology.impl;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.onosproject.net.Link.State.ACTIVE;
import static org.onosproject.provider.pcep.topology.impl.PcepTopologyProvider.LABEL_STACK_CAPABILITY;
import static org.onosproject.provider.pcep.topology.impl.PcepTopologyProvider.LSRID;
import static org.onosproject.provider.pcep.topology.impl.PcepTopologyProvider.PCECC_CAPABILITY;
import static org.onosproject.provider.pcep.topology.impl.PcepTopologyProvider.SR_CAPABILITY;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onlab.packet.ChassisId;
import org.onlab.packet.IpAddress;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DefaultDevice;
import org.onosproject.net.DefaultLink;
import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Link;
import org.onosproject.net.MastershipRole;
import org.onosproject.net.device.DeviceDescription;
import org.onosproject.net.device.DeviceProvider;
import org.onosproject.net.device.DeviceProviderRegistry;
import org.onosproject.net.device.DeviceProviderService;
import org.onosproject.net.device.DeviceServiceAdapter;
import org.onosproject.net.device.PortDescription;
import org.onosproject.net.device.PortStatistics;
import org.onosproject.net.link.LinkDescription;
import org.onosproject.net.link.LinkProvider;
import org.onosproject.net.link.LinkProviderRegistry;
import org.onosproject.net.link.LinkProviderService;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.pcep.controller.ClientCapability;
import org.onosproject.pcep.controller.PccId;
import org.onosproject.pcep.controller.PcepClient;
import org.onosproject.pcep.controller.PcepNodeListener;
/**
* Test for PCEP topology provider.
*/
public class PcepTopologyProviderTest {
private static final String UNKNOWN = new String("unknown");
public static ProviderId providerId = new ProviderId("l3", "foo");
private final PcepClientControllerAdapter clientController = new PcepClientControllerAdapter();
private final PcepTopologyProvider provider = new PcepTopologyProvider();
private final MockDeviceRegistry nodeRegistry = new MockDeviceRegistry();
private final PcepControllerAdapter controller = new PcepControllerAdapter();
private final MockLinkRegistry linkRegistry = new MockLinkRegistry();
private final MockDeviceService deviceService = new MockDeviceService();
private Map<DeviceId, Device> deviceMap = new HashMap<>();
@Before
public void startUp() {
provider.pcepClientController = clientController;
provider.deviceProviderRegistry = nodeRegistry;
provider.linkProviderRegistry = linkRegistry;
provider.controller = controller;
provider.deviceService = deviceService;
provider.activate();
}
@After
public void tearDown() {
provider.deactivate();
provider.deviceProviderRegistry = null;
provider.pcepClientController = null;
provider.linkProviderRegistry = null;
provider.controller = null;
provider.deviceService = null;
}
/* Class implement device test registry */
private class MockLinkRegistry implements LinkProviderRegistry {
LinkProvider linkProvider;
Set<Link> links = new HashSet<>();
@Override
public LinkProviderService register(LinkProvider provider) {
this.linkProvider = provider;
return new MockProviderService();
}
@Override
public void unregister(LinkProvider provider) {
// TODO Auto-generated method stub
}
@Override
public Set<ProviderId> getProviders() {
return null;
}
private class MockProviderService implements LinkProviderService {
@Override
public void linkDetected(LinkDescription linkDescription) {
links.add(DefaultLink.builder().src(linkDescription.src())
.dst(linkDescription.dst()).state(ACTIVE).type(linkDescription.type())
.providerId(ProviderId.NONE).build());
}
@Override
public void linkVanished(LinkDescription linkDescription) {
links.remove(DefaultLink.builder().src(linkDescription.src())
.dst(linkDescription.dst()).state(ACTIVE).type(linkDescription.type())
.providerId(ProviderId.NONE).build());
}
@Override
public void linksVanished(ConnectPoint connectPoint) {
// TODO Auto-generated method stub
}
@Override
public void linksVanished(DeviceId deviceId) {
// TODO Auto-generated method stub
}
@Override
public LinkProvider provider() {
// TODO Auto-generated method stub
return null;
}
}
}
/* Class implement device test registry */
private class MockDeviceRegistry implements DeviceProviderRegistry {
DeviceProvider provider;
Set<DeviceId> connected = new HashSet<>();
@Override
public DeviceProviderService register(DeviceProvider provider) {
this.provider = provider;
return new MockProviderService();
}
@Override
public void unregister(DeviceProvider provider) {
}
@Override
public Set<ProviderId> getProviders() {
return null;
}
private class MockProviderService implements DeviceProviderService {
@Override
public DeviceProvider provider() {
return null;
}
@Override
public void deviceConnected(DeviceId deviceId, DeviceDescription deviceDescription) {
connected.add(deviceId);
Device device = new DefaultDevice(ProviderId.NONE, deviceId, Device.Type.ROUTER, UNKNOWN, UNKNOWN,
UNKNOWN, UNKNOWN, new ChassisId(), deviceDescription.annotations());
deviceMap.put(deviceId, device);
}
@Override
public void deviceDisconnected(DeviceId deviceId) {
connected.remove(deviceId);
deviceMap.remove(deviceId);
}
@Override
public void updatePorts(DeviceId deviceId, List<PortDescription> portDescriptions) {
// TODO Auto-generated method stub
}
@Override
public void portStatusChanged(DeviceId deviceId, PortDescription portDescription) {
// TODO Auto-generated method stub
}
@Override
public void receivedRoleReply(DeviceId deviceId, MastershipRole requested, MastershipRole response) {
// TODO Auto-generated method stub
}
@Override
public void updatePortStatistics(DeviceId deviceId, Collection<PortStatistics> portStatistics) {
// TODO Auto-generated method stub
}
}
}
/* Mock test for device service */
private class MockDeviceService extends DeviceServiceAdapter {
@Override
public Device getDevice(DeviceId deviceId) {
return deviceMap.get(deviceId);
}
}
/**
* Adds the PCEP device and removes it.
*/
@Test
public void testPcepTopologyProviderTestAddDevice1() {
PcepClient pc = clientController.getClient(PccId.pccId(IpAddress.valueOf("1.1.1.1")));
for (PcepNodeListener l : clientController.pcepNodeListener) {
pc.setCapability(new ClientCapability(true, true, false, true, true));
l.addNode(pc);
assertThat(nodeRegistry.connected.size(), is(1));
assertThat(deviceMap.keySet().iterator().next(), is(DeviceId.deviceId("l3:1.1.1.1")));
assertThat(deviceMap.values().iterator().next().annotations().value(LABEL_STACK_CAPABILITY), is("true"));
assertThat(deviceMap.values().iterator().next().annotations().value(LSRID), is("1.1.1.1"));
assertThat(deviceMap.values().iterator().next().annotations().value(PCECC_CAPABILITY), is("true"));
assertThat(deviceMap.values().iterator().next().annotations().value(SR_CAPABILITY), is("true"));
l.deleteNode(pc.getPccId());
assertThat(nodeRegistry.connected.size(), is(0));
}
}
}
......@@ -6,6 +6,7 @@ COMPILE_DEPS = [
'//incubator/api:onos-incubator-api',
'//protocols/pcep/pcepio:onos-protocols-pcep-pcepio',
'//protocols/pcep/api:onos-protocols-pcep-api',
'//protocols/pcep/ctl:onos-protocols-pcep-ctl',
]
TEST_DEPS = [
......
......@@ -49,5 +49,10 @@
<version>${project.version} </version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-pcep-controller-impl</artifactId>
<version>${project.version} </version>
</dependency>
</dependencies>
</project>
......
......@@ -17,17 +17,22 @@ package org.onosproject.provider.pcep.tunnel.impl;
import static org.junit.Assert.assertNotNull;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.RejectedExecutionException;
import org.jboss.netty.channel.Channel;
import org.onosproject.pcep.controller.ClientCapability;
import org.onosproject.pcep.controller.LspKey;
import org.onosproject.pcep.controller.PccId;
import org.onosproject.pcep.controller.PcepClient;
import org.onosproject.pcep.controller.PcepSyncStatus;
import org.onosproject.pcepio.protocol.PcepFactories;
import org.onosproject.pcepio.protocol.PcepFactory;
import org.onosproject.pcepio.protocol.PcepMessage;
import org.onosproject.pcepio.protocol.PcepStateReport;
import org.onosproject.pcepio.protocol.PcepVersion;
/**
......@@ -45,6 +50,8 @@ public class PcepClientAdapter implements PcepClient {
private PcepVersion pcepVersion;
private PcepSyncStatus lspDbSyncStatus;
private PcepSyncStatus labelDbSyncStatus;
private Map<LspKey, Boolean> lspDelegationInfo = new HashMap<>();
private Map<PccId, List<PcepStateReport>> sycRptCache = new HashMap<>();
/**
* Initialize instance with specified parameters.
......@@ -139,4 +146,45 @@ public class PcepClientAdapter implements PcepClient {
public ClientCapability capability() {
return capability;
}
@Override
public void addNode(PcepClient pc) {
}
@Override
public void deleteNode(PccId pccId) {
}
@Override
public void setLspAndDelegationInfo(LspKey lspKey, boolean dFlag) {
lspDelegationInfo.put(lspKey, dFlag);
}
@Override
public Boolean delegationInfo(LspKey lspKey) {
return lspDelegationInfo.get(lspKey);
}
@Override
public void initializeSyncMsgList(PccId pccId) {
List<PcepStateReport> rptMsgList = new LinkedList<>();
sycRptCache.put(pccId, rptMsgList);
}
@Override
public List<PcepStateReport> getSyncMsgList(PccId pccId) {
return sycRptCache.get(pccId);
}
@Override
public void removeSyncMsgList(PccId pccId) {
sycRptCache.remove(pccId);
}
@Override
public void addSyncMsgToList(PccId pccId, PcepStateReport rptMsg) {
List<PcepStateReport> rptMsgList = sycRptCache.get(pccId);
rptMsgList.add(rptMsg);
sycRptCache.put(pccId, rptMsgList);
}
}
......
......@@ -24,13 +24,13 @@ import java.util.concurrent.ConcurrentHashMap;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Deactivate;
import org.onlab.packet.IpAddress;
import org.onosproject.pcep.controller.ClientCapability;
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;
......@@ -57,6 +57,8 @@ public class PcepClientControllerAdapter implements PcepClientController {
protected Set<PcepClientListener> pcepClientListener = new HashSet<>();
protected Set<PcepEventListener> pcepEventListener = Sets.newHashSet();
public Set<PcepNodeListener> pcepNodeListener = Sets.newHashSet();
protected Set<PcepPacketListener> pcepPacketListener = Sets.newHashSet();
@Activate
public void activate() {
......@@ -73,16 +75,11 @@ public class PcepClientControllerAdapter implements PcepClientController {
@Override
public PcepClient getClient(PccId pccId) {
if (null != connectedClients.get(pccId)) {
if (connectedClients.get(pccId) != null) {
return connectedClients.get(pccId);
}
PcepClientAdapter pc = new PcepClientAdapter();
if (pccId.ipAddress().equals(IpAddress.valueOf(0xC010103))
|| pccId.ipAddress().equals(IpAddress.valueOf(0xB6024E22))) {
pc.setCapability(new ClientCapability(true, false, false));
} else {
pc.setCapability(new ClientCapability(true, true, true));
}
pc.init(PccId.pccId(pccId.ipAddress()), PcepVersion.PCEP_1);
connectedClients.put(pccId, pc);
return pc;
......@@ -96,6 +93,16 @@ public class PcepClientControllerAdapter implements PcepClientController {
}
@Override
public void addNodeListener(PcepNodeListener listener) {
pcepNodeListener.add(listener);
}
@Override
public void removeNodeListener(PcepNodeListener listener) {
pcepNodeListener.remove(listener);
}
@Override
public void removeListener(PcepClientListener listener) {
this.pcepClientListener.remove(listener);
}
......@@ -111,6 +118,16 @@ public class PcepClientControllerAdapter implements PcepClientController {
}
@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);
}
......@@ -254,5 +271,25 @@ public class PcepClientControllerAdapter implements PcepClientController {
public void processPcepMessage(PccId pccId, PcepMessage m) {
processClientMessage(pccId, m);
}
@Override
public void addNode(PcepClient pc) {
for (PcepNodeListener l : pcepNodeListener) {
l.addNode(pc);
}
}
@Override
public void deleteNode(PccId pccId) {
for (PcepNodeListener l : pcepNodeListener) {
l.deleteNode(pccId);
}
}
@Override
public boolean analyzeSyncMsgList(PccId pccId) {
// TODO Auto-generated method stub
return false;
}
}
}
......
......@@ -40,6 +40,7 @@ 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.TunnelName;
import org.onosproject.mastership.MastershipServiceAdapter;
import org.onosproject.net.Annotations;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DefaultAnnotations;
......@@ -49,7 +50,10 @@ import org.onosproject.net.IpElementId;
import org.onosproject.net.Link;
import org.onosproject.net.Path;
import org.onosproject.net.PortNumber;
import org.onosproject.net.device.DeviceServiceAdapter;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.pcep.controller.ClientCapability;
import org.onosproject.pcep.controller.PccId;
import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv;
/**
......@@ -64,12 +68,16 @@ public class PcepReleaseTunnelProviderTest {
private final PcepControllerAdapter ctl = new PcepControllerAdapter();
private final PcepTunnelApiMapper pcepTunnelAPIMapper = new PcepTunnelApiMapper();
private final TunnelServiceAdapter tunnelService = new TunnelServiceAdapter();
private final DeviceServiceAdapter deviceService = new DeviceServiceAdapter();
private final MastershipServiceAdapter mastershipService = new MastershipServiceAdapter();
@Before
public void setUp() throws IOException {
tunnelProvider.tunnelProviderRegistry = registry;
tunnelProvider.pcepClientController = controller;
tunnelProvider.controller = ctl;
tunnelProvider.deviceService = deviceService;
tunnelProvider.mastershipService = mastershipService;
tunnelProvider.tunnelService = tunnelService;
tunnelProvider.pcepTunnelApiMapper = pcepTunnelAPIMapper;
tunnelProvider.cfgService = new ComponentConfigAdapter();
......@@ -125,6 +133,8 @@ public class PcepReleaseTunnelProviderTest {
tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData);
controller.getClient(PccId.pccId(IpAddress.valueOf(0xB6024E20))).setCapability(
new ClientCapability(true, true, true, true, true));
tunnelProvider.releaseTunnel(tunnel);
assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
......@@ -179,6 +189,8 @@ public class PcepReleaseTunnelProviderTest {
tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData);
controller.getClient(PccId.pccId(IpAddress.valueOf(0xB6024E22))).setCapability(
new ClientCapability(true, false, false, true, true));
tunnelProvider.releaseTunnel(tunnel);
assertThat(tunnelProvider.pcepTunnelApiMapper.checkFromTunnelRequestQueue(1), is(false));
......@@ -233,6 +245,8 @@ public class PcepReleaseTunnelProviderTest {
tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData);
controller.getClient(PccId.pccId(IpAddress.valueOf(0xB6024E20))).setCapability(
new ClientCapability(true, true, true, true, true));
tunnelProvider.releaseTunnel(tunnel);
assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
......@@ -287,6 +301,8 @@ public class PcepReleaseTunnelProviderTest {
tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData);
controller.getClient(PccId.pccId(IpAddress.valueOf(0xB6024E20))).setCapability(
new ClientCapability(true, true, true, true, true));
tunnelProvider.releaseTunnel(tunnel);
assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
......@@ -298,5 +314,7 @@ public class PcepReleaseTunnelProviderTest {
tunnelProvider.controller = null;
tunnelProvider.pcepClientController = null;
tunnelProvider.tunnelProviderRegistry = null;
tunnelProvider.deviceService = null;
tunnelProvider.mastershipService = null;
}
}
......
......@@ -40,6 +40,7 @@ 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.TunnelName;
import org.onosproject.mastership.MastershipServiceAdapter;
import org.onosproject.net.Annotations;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DefaultAnnotations;
......@@ -49,7 +50,10 @@ import org.onosproject.net.IpElementId;
import org.onosproject.net.Link;
import org.onosproject.net.Path;
import org.onosproject.net.PortNumber;
import org.onosproject.net.device.DeviceServiceAdapter;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.pcep.controller.ClientCapability;
import org.onosproject.pcep.controller.PccId;
/**
* Test for PCEP setup tunnel.
......@@ -62,12 +66,16 @@ public class PcepSetupTunnelProviderTest {
private final PcepClientControllerAdapter controller = new PcepClientControllerAdapter();
private final PcepControllerAdapter ctl = new PcepControllerAdapter();
private final TunnelServiceAdapter tunnelService = new TunnelServiceAdapter();
private final DeviceServiceAdapter deviceService = new DeviceServiceAdapter();
private final MastershipServiceAdapter mastershipService = new MastershipServiceAdapter();
@Before
public void setUp() throws IOException {
tunnelProvider.tunnelProviderRegistry = registry;
tunnelProvider.pcepClientController = controller;
tunnelProvider.controller = ctl;
tunnelProvider.deviceService = deviceService;
tunnelProvider.mastershipService = mastershipService;
tunnelProvider.cfgService = new ComponentConfigAdapter();
tunnelProvider.tunnelService = tunnelService;
tunnelProvider.activate();
......@@ -111,6 +119,8 @@ public class PcepSetupTunnelProviderTest {
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
path, annotations);
controller.getClient(PccId.pccId(IpAddress.valueOf(0xC010101))).setCapability(
new ClientCapability(true, true, true, true, true));
tunnelProvider.setupTunnel(tunnel, path);
assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
......@@ -154,6 +164,8 @@ public class PcepSetupTunnelProviderTest {
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
path, annotations);
controller.getClient(PccId.pccId(IpAddress.valueOf(0xC010103))).setCapability(
new ClientCapability(true, true, true, true, true));
tunnelProvider.setupTunnel(tunnel, path);
assertThat(tunnelProvider.pcepTunnelApiMapper.checkFromTunnelRequestQueue(1), is(false));
......@@ -197,6 +209,8 @@ public class PcepSetupTunnelProviderTest {
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
path, annotations);
controller.getClient(PccId.pccId(IpAddress.valueOf(0xC010101))).setCapability(
new ClientCapability(true, true, true, true, true));
tunnelProvider.setupTunnel(tunnel, path);
assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
......@@ -240,6 +254,8 @@ public class PcepSetupTunnelProviderTest {
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
path, annotations);
controller.getClient(PccId.pccId(IpAddress.valueOf(0xC010101))).setCapability(
new ClientCapability(true, true, true, true, true));
tunnelProvider.setupTunnel(tunnel, path);
assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
......@@ -251,5 +267,7 @@ public class PcepSetupTunnelProviderTest {
tunnelProvider.controller = null;
tunnelProvider.pcepClientController = null;
tunnelProvider.tunnelProviderRegistry = null;
tunnelProvider.deviceService = null;
tunnelProvider.mastershipService = null;
}
}
......
......@@ -35,6 +35,7 @@ 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.TunnelName;
import org.onosproject.mastership.MastershipServiceAdapter;
import org.onosproject.net.Annotations;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DefaultAnnotations;
......@@ -44,7 +45,10 @@ import org.onosproject.net.IpElementId;
import org.onosproject.net.Link;
import org.onosproject.net.Path;
import org.onosproject.net.PortNumber;
import org.onosproject.net.device.DeviceServiceAdapter;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.pcep.controller.ClientCapability;
import org.onosproject.pcep.controller.PccId;
import org.onosproject.cfg.ComponentConfigAdapter;
public class PcepTunnelProviderTest {
......@@ -55,6 +59,8 @@ public class PcepTunnelProviderTest {
private final PcepClientControllerAdapter controller = new PcepClientControllerAdapter();
private final PcepControllerAdapter ctl = new PcepControllerAdapter();
private final TunnelServiceAdapter tunnelService = new TunnelServiceAdapter();
private final DeviceServiceAdapter deviceService = new DeviceServiceAdapter();
private final MastershipServiceAdapter mastershipService = new MastershipServiceAdapter();
@Test
public void testCasePcepSetupTunnel() {
......@@ -62,6 +68,8 @@ public class PcepTunnelProviderTest {
tunnelProvider.tunnelProviderRegistry = registry;
tunnelProvider.pcepClientController = controller;
tunnelProvider.controller = ctl;
tunnelProvider.deviceService = deviceService;
tunnelProvider.mastershipService = mastershipService;
tunnelProvider.cfgService = new ComponentConfigAdapter();
tunnelProvider.tunnelService = tunnelService;
tunnelProvider.activate();
......@@ -99,6 +107,8 @@ public class PcepTunnelProviderTest {
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
path, annotations);
controller.getClient(PccId.pccId(IpAddress.valueOf(0xC010101))).setCapability(
new ClientCapability(true, true, true, true, true));
tunnelProvider.setupTunnel(tunnel, path);
......@@ -109,6 +119,8 @@ public class PcepTunnelProviderTest {
public void tearDown() throws IOException {
tunnelProvider.deactivate();
tunnelProvider.controller = null;
tunnelProvider.deviceService = null;
tunnelProvider.mastershipService = null;
tunnelProvider.pcepClientController = null;
tunnelProvider.tunnelProviderRegistry = null;
}
......
......@@ -47,6 +47,10 @@ import org.onosproject.net.Link;
import org.onosproject.net.Path;
import org.onosproject.net.PortNumber;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.pcep.controller.ClientCapability;
import org.onosproject.pcep.controller.LspKey;
import org.onosproject.pcep.controller.PccId;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv;
import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITH_SIGNALLING;
......@@ -99,7 +103,7 @@ public class PcepUpdateTunnelProviderTest {
ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023));
ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10024));
Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
.type(Link.Type.DIRECT).build();
......@@ -108,6 +112,8 @@ public class PcepUpdateTunnelProviderTest {
path = new DefaultPath(pid, links, 20, EMPTY);
Annotations annotations = DefaultAnnotations.builder()
.set(PcepAnnotationKeys.PLSP_ID, "1")
.set(PcepAnnotationKeys.LOCAL_LSP_ID, "1")
.set(LSP_SIG_TYPE, WITH_SIGNALLING.name())
.build();
......@@ -124,6 +130,12 @@ public class PcepUpdateTunnelProviderTest {
tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData);
PccId pccId = PccId.pccId(IpAddress.valueOf(0xD010101));
PcepClientAdapter pc = new PcepClientAdapter();
pc.init(pccId, PcepVersion.PCEP_1);
controller.getClient(pccId).setLspAndDelegationInfo(new LspKey(1, (short) 1), true);
controller.getClient(pccId).setCapability(new ClientCapability(true, true, true, true, true));
tunnelProvider.updateTunnel(tunnel, path);
assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
}
......@@ -137,7 +149,7 @@ public class PcepUpdateTunnelProviderTest {
Path path;
ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
List<Link> links = new ArrayList<>();
IpAddress srcIp = IpAddress.valueOf(0xC010103);
IpAddress srcIp = IpAddress.valueOf(0xD010101);
IpElementId srcElementId = IpElementId.ipElement(srcIp);
IpAddress dstIp = IpAddress.valueOf(0xD010102);
......@@ -151,7 +163,7 @@ public class PcepUpdateTunnelProviderTest {
ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023));
ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10024));
Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
.type(Link.Type.DIRECT).build();
......@@ -161,6 +173,8 @@ public class PcepUpdateTunnelProviderTest {
Annotations annotations = DefaultAnnotations.builder()
.set(LSP_SIG_TYPE, WITH_SIGNALLING.name())
.set(PcepAnnotationKeys.PLSP_ID, "1")
.set(PcepAnnotationKeys.LOCAL_LSP_ID, "1")
.build();
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
......@@ -176,6 +190,12 @@ public class PcepUpdateTunnelProviderTest {
tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData);
PccId pccId = PccId.pccId(IpAddress.valueOf(0xD010101));
PcepClientAdapter pc = new PcepClientAdapter();
pc.init(pccId, PcepVersion.PCEP_1);
controller.getClient(pccId).setLspAndDelegationInfo(new LspKey(1, (short) 1), true);
controller.getClient(pccId).setCapability(new ClientCapability(true, true, true, true, true));
tunnelProvider.updateTunnel(tunnel, path);
assertThat(tunnelProvider.pcepTunnelApiMapper.checkFromTunnelRequestQueue(1), is(false));
}
......@@ -203,7 +223,7 @@ public class PcepUpdateTunnelProviderTest {
ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023));
ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10024));
Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
.type(Link.Type.DIRECT).build();
......@@ -213,6 +233,8 @@ public class PcepUpdateTunnelProviderTest {
Annotations annotations = DefaultAnnotations.builder()
.set(LSP_SIG_TYPE, SR_WITHOUT_SIGNALLING.name())
.set(PcepAnnotationKeys.PLSP_ID, "1")
.set(PcepAnnotationKeys.LOCAL_LSP_ID, "1")
.build();
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
......@@ -228,6 +250,12 @@ public class PcepUpdateTunnelProviderTest {
tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData);
PccId pccId = PccId.pccId(IpAddress.valueOf(0xD010101));
PcepClientAdapter pc = new PcepClientAdapter();
pc.init(pccId, PcepVersion.PCEP_1);
controller.getClient(pccId).setLspAndDelegationInfo(new LspKey(1, (short) 1), true);
controller.getClient(pccId).setCapability(new ClientCapability(true, true, true, true, true));
tunnelProvider.updateTunnel(tunnel, path);
assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
}
......@@ -255,7 +283,7 @@ public class PcepUpdateTunnelProviderTest {
ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023));
ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10024));
Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
.type(Link.Type.DIRECT).build();
......@@ -265,6 +293,8 @@ public class PcepUpdateTunnelProviderTest {
Annotations annotations = DefaultAnnotations.builder()
.set(LSP_SIG_TYPE, WITHOUT_SIGNALLING_AND_WITHOUT_SR.name())
.set(PcepAnnotationKeys.PLSP_ID, "1")
.set(PcepAnnotationKeys.LOCAL_LSP_ID, "1")
.build();
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
......@@ -280,6 +310,12 @@ public class PcepUpdateTunnelProviderTest {
tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData);
PccId pccId = PccId.pccId(IpAddress.valueOf(0xD010101));
PcepClientAdapter pc = new PcepClientAdapter();
pc.init(pccId, PcepVersion.PCEP_1);
controller.getClient(pccId).setLspAndDelegationInfo(new LspKey(1, (short) 1), true);
controller.getClient(pccId).setCapability(new ClientCapability(true, true, true, true, true));
tunnelProvider.updateTunnel(tunnel, path);
assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
}
......