Avantika-Huawei

[ONOS-4170] LSP-DB sync

Change-Id: Icda3afd9cca8d1fb8c58b44da6bc26064b300388
Showing 27 changed files with 561 additions and 18 deletions
......@@ -30,6 +30,9 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import org.onlab.packet.Ethernet;
import org.onlab.packet.IPv4;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
......@@ -38,6 +41,7 @@ import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.TCP;
import org.onlab.util.Bandwidth;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
......@@ -139,6 +143,7 @@ public class PceManager implements PceService {
private static final String TRUE = "true";
private static final String FALSE = "false";
private static final String END_OF_SYNC_IP_PREFIX = "0.0.0.0/32";
public static final int PCEP_PORT = 4189;
private IdGenerator localLspIdIdGen;
protected DistributedSet<Short> localLspIdFreeList;
......@@ -635,7 +640,7 @@ public class PceManager implements PceService {
LinkEvent linkEvent = (LinkEvent) e;
if (linkEvent.type() == LinkEvent.Type.LINK_REMOVED) {
tunnelService.queryTunnel(MPLS).forEach(t -> {
if (t.path().links().contains(((Link) e.subject()))) {
if (t.path().links().contains((e.subject()))) {
// Check whether this ONOS instance is master for ingress device if yes,
// recompute and send update
checkForMasterAndUpdateTunnel(t.path().src().deviceId(), t);
......@@ -949,12 +954,30 @@ public class PceManager implements PceService {
public void process(PacketContext context) {
// Stop processing if the packet has been handled, since we
// can't do any more to it.
if (context.isHandled()) {
return;
}
InboundPacket pkt = context.inPacket();
if (pkt == null) {
return;
}
Ethernet ethernet = pkt.parsed();
if (ethernet == null || ethernet.getEtherType() != Ethernet.TYPE_IPV4) {
return;
}
IPv4 ipPacket = (IPv4) ethernet.getPayload();
if (ipPacket == null || ipPacket.getProtocol() != IPv4.PROTOCOL_TCP) {
return;
}
TCP tcp = (TCP) ipPacket.getPayload();
if (tcp == null || tcp.getDestinationPort() != PCEP_PORT) {
return;
}
syncLabelDb(pkt.receivedFrom().deviceId());
}
}
......
......@@ -26,7 +26,6 @@ import static org.onosproject.incubator.net.tunnel.Tunnel.State.ESTABLISHED;
import static org.onosproject.net.MastershipRole.MASTER;
import java.net.URISyntaxException;
import java.nio.ByteBuffer;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
......@@ -44,6 +43,7 @@ import org.onlab.junit.TestUtils;
import org.onlab.junit.TestUtils.TestUtilsException;
import org.onlab.packet.Ethernet;
import org.onlab.packet.IPv4;
import org.onlab.packet.TCP;
import org.onlab.util.Bandwidth;
import org.onosproject.common.DefaultTopologyGraph;
import org.onosproject.core.ApplicationId;
......@@ -112,6 +112,7 @@ import org.onosproject.pce.util.FlowObjServiceAdapter;
import org.onosproject.store.service.TestStorageService;
import com.google.common.collect.ImmutableSet;
import static org.onosproject.pce.pceservice.PceManager.PCEP_PORT;
/**
* Tests the functions of PceManager.
......@@ -675,21 +676,18 @@ public class PceManagerTest {
* Tests packet in to trigger label DB sync.
*/
@Test
public void packetProcessingTest() throws URISyntaxException {
public void packetProcessingTest1() throws URISyntaxException {
build4RouterTopo(false, true, true, true, 0); // This also initializes devices etc.
final int srcHost = 2;
final int dstHost = 5;
LabelResourceId node1Label = LabelResourceId.labelResourceId(5200);
LabelResourceId node2Label = LabelResourceId.labelResourceId(5201);
pceManager.pceStore.addGlobalNodeLabel(D1.deviceId(), node1Label);
pceManager.pceStore.addGlobalNodeLabel(D2.deviceId(), node2Label);
ConnectPoint src = new ConnectPoint(D1.deviceId(), PortNumber.portNumber(srcHost));
ConnectPoint dst = new ConnectPoint(D2.deviceId(), PortNumber.portNumber(dstHost));
ConnectPoint src = new ConnectPoint(D1.deviceId(), PortNumber.portNumber(1));
ConnectPoint dst = new ConnectPoint(D2.deviceId(), PortNumber.portNumber(2));
Link link1 = DefaultLink.builder().src(src).dst(dst).state(ACTIVE).type(DIRECT)
.providerId(new ProviderId("eth", "1")).build();
......@@ -697,24 +695,66 @@ public class PceManagerTest {
LabelResourceId link1Label = LabelResourceId.labelResourceId(5204);
pceManager.pceStore.addAdjLabel(link1, link1Label);
Ethernet eth;
IPv4 ipv4;
TCP tcp = new TCP();
tcp.setDestinationPort(PCEP_PORT);
IPv4 ipv4 = new IPv4();
ipv4.setProtocol(IPv4.PROTOCOL_TCP);
ipv4.setPayload(tcp);
ipv4 = new IPv4();
eth = new Ethernet();
Ethernet eth = new Ethernet();
eth.setEtherType(Ethernet.TYPE_IPV4);
eth.setPayload(ipv4);
eth.setSourceMACAddress("00:00:00:10:00:0" + srcHost).setDestinationMACAddress("00:00:00:10:00:0" + dstHost);
InboundPacket inPkt = new DefaultInboundPacket(new ConnectPoint(D1.deviceId(), PortNumber.portNumber(srcHost)),
eth, ByteBuffer.wrap(eth.serialize()));
InboundPacket inPkt = new DefaultInboundPacket(new ConnectPoint(D1.deviceId(),
PortNumber.portNumber(PCEP_PORT)),
eth, null);
pktProcessor.process(new MockPcepPacketContext(inPkt, null));
assertThat(flowsDownloaded, is(4));
}
/**
* Tests faulty packet in to trigger label DB sync.
*/
@Test
public void packetProcessingTest2() throws URISyntaxException {
build4RouterTopo(false, true, true, true, 0); // This also initializes devices etc.
LabelResourceId node1Label = LabelResourceId.labelResourceId(5200);
LabelResourceId node2Label = LabelResourceId.labelResourceId(5201);
pceManager.pceStore.addGlobalNodeLabel(D1.deviceId(), node1Label);
pceManager.pceStore.addGlobalNodeLabel(D2.deviceId(), node2Label);
ConnectPoint src = new ConnectPoint(D1.deviceId(), PortNumber.portNumber(1));
ConnectPoint dst = new ConnectPoint(D2.deviceId(), PortNumber.portNumber(2));
Link link1 = DefaultLink.builder().src(src).dst(dst).state(ACTIVE).type(DIRECT)
.providerId(new ProviderId("eth", "1")).build();
LabelResourceId link1Label = LabelResourceId.labelResourceId(5204);
pceManager.pceStore.addAdjLabel(link1, link1Label);
TCP tcp = new TCP(); // Not set the 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);
InboundPacket inPkt = new DefaultInboundPacket(new ConnectPoint(D1.deviceId(),
PortNumber.portNumber(PCEP_PORT)),
eth, null);
pktProcessor.process(new MockPcepPacketContext(inPkt, null));
assertThat(flowsDownloaded, is(0));
}
/**
* Tests tunnel events added and removed.
*/
@Test
......
......@@ -2,6 +2,7 @@ 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 (
......
......@@ -52,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>
......
......@@ -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).
......@@ -165,4 +166,34 @@ public interface PcepClient {
* @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);
}
......
......@@ -85,6 +85,20 @@ public interface PcepClientController {
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;
public interface PcepPacketListener {
void sendPacketIn(PccId pccId);
}
......@@ -73,4 +73,12 @@ public interface PcepAgent {
* @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 (
......
......@@ -19,6 +19,8 @@ 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;
......@@ -36,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;
......@@ -70,6 +73,7 @@ public class PcepClientImpl implements PcepClientDriver {
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) {
......@@ -192,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
......@@ -254,6 +265,29 @@ public class PcepClientImpl implements PcepClientDriver {
}
@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) {
......
......@@ -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);
......
<!--
~ Copyright 2016-present Open Networking Laboratory
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-pcep-providers</artifactId>
<version>1.7.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</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
......@@ -28,5 +28,6 @@
<module>topology</module>
<module>tunnel</module>
<module>app</module>
<module>packet</module>
</modules>
</project>
\ No newline at end of file
......
......@@ -31,6 +31,7 @@ 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;
/**
......@@ -161,4 +162,28 @@ public class PcepClientAdapter implements PcepClient {
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
}
}
......
......@@ -32,6 +32,7 @@ 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;
......@@ -280,5 +281,23 @@ public class PcepClientControllerAdapter implements PcepClientController {
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
}
}
......
......@@ -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 = [
......
......@@ -50,5 +50,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>
......
......@@ -18,6 +18,7 @@ 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;
......@@ -31,6 +32,7 @@ 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;
/**
......@@ -49,6 +51,7 @@ public class PcepClientAdapter implements PcepClient {
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.
......@@ -161,4 +164,27 @@ public class PcepClientAdapter implements PcepClient {
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);
}
}
......
......@@ -30,6 +30,7 @@ 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 +58,7 @@ public class PcepClientControllerAdapter implements PcepClientController {
protected Set<PcepEventListener> pcepEventListener = Sets.newHashSet();
public Set<PcepNodeListener> pcepNodeListener = Sets.newHashSet();
protected Set<PcepPacketListener> pcepPacketListener = Sets.newHashSet();
@Activate
public void activate() {
......@@ -116,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);
}
......@@ -273,5 +285,11 @@ public class PcepClientControllerAdapter implements PcepClientController {
l.deleteNode(pccId);
}
}
@Override
public boolean analyzeSyncMsgList(PccId pccId) {
// TODO Auto-generated method stub
return false;
}
}
}
......