PCEP Protocol code restructured to move under PCEP Server code for more readability. Later Client code can be added under client folder.
Change-Id: Ie79599a170d94d8e0a00e0d034b083b3894199ee
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/ClientCapability.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/ClientCapability.java
new file mode 100644
index 0000000..2a6c71a
--- /dev/null
+++ b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/ClientCapability.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2016-present Open Networking Foundation
+ *
+ * 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.server;
+
+import java.util.Objects;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Representation of capabilities supported by client.
+ */
+public class ClientCapability {
+ private boolean pceccCapability;
+ private boolean statefulPceCapability;
+ private boolean pcInstantiationCapability;
+ private boolean labelStackCapability;
+ private boolean srCapability;
+
+ /**
+ * Creates new instance of client capability.
+ *
+ * @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,
+ 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;
+ }
+
+ /**
+ * Obtains PCECC capability.
+ *
+ * @return true if client supports PCECC capability otherwise false
+ */
+ public boolean pceccCapability() {
+ return pceccCapability;
+ }
+
+ /**
+ * Obtains stateful PCE capability.
+ *
+ * @return true if client supports stateful PCE capability otherwise false
+ */
+ public boolean statefulPceCapability() {
+ return statefulPceCapability;
+ }
+
+ /**
+ * Obtains PC initiation capability.
+ *
+ * @return true if client supports PC initiation capability otherwise false
+ */
+ public boolean pcInstantiationCapability() {
+ return pcInstantiationCapability;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(pceccCapability, statefulPceCapability, pcInstantiationCapability, labelStackCapability,
+ srCapability);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof ClientCapability) {
+ ClientCapability other = (ClientCapability) obj;
+ return Objects.equals(pceccCapability, other.pceccCapability)
+ && Objects.equals(statefulPceCapability, other.statefulPceCapability)
+ && Objects.equals(pcInstantiationCapability, other.pcInstantiationCapability)
+ && Objects.equals(labelStackCapability, other.labelStackCapability)
+ && Objects.equals(srCapability, other.srCapability);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("pceccCapability", pceccCapability)
+ .add("statefulPceCapability", statefulPceCapability)
+ .add("pcInstantiationCapability", pcInstantiationCapability)
+ .add("labelStackCapability", labelStackCapability)
+ .add("srCapability", srCapability)
+ .toString();
+ }
+}
\ No newline at end of file
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/LspKey.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/LspKey.java
new file mode 100644
index 0000000..2cba240
--- /dev/null
+++ b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/LspKey.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2016-present Open Networking Foundation
+ *
+ * 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.server;
+
+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
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/LspType.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/LspType.java
new file mode 100644
index 0000000..6cfcd37
--- /dev/null
+++ b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/LspType.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2016-present Open Networking Foundation
+ *
+ * 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.server;
+
+/**
+ * Representation of LSP type.
+ */
+public enum LspType {
+ /**
+ * Signifies that path is created via signaling mode.
+ */
+ WITH_SIGNALLING(0),
+
+ /**
+ * Signifies that path is created via SR mode.
+ */
+ SR_WITHOUT_SIGNALLING(1),
+
+ /**
+ * Signifies that path is created via without signaling and without SR mode.
+ */
+ WITHOUT_SIGNALLING_AND_WITHOUT_SR(2);
+
+ int value;
+
+ /**
+ * Assign val with the value as the LSP type.
+ *
+ * @param val LSP type
+ */
+ LspType(int val) {
+ value = val;
+ }
+
+ /**
+ * Returns value of LSP type.
+ *
+ * @return LSP type
+ */
+ public byte type() {
+ return (byte) value;
+ }
+}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PccId.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PccId.java
new file mode 100644
index 0000000..9fdd605
--- /dev/null
+++ b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PccId.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2015-present Open Networking Foundation
+ *
+ * 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.server;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.util.Identifier;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+/**
+ * The class representing a network client pc ip.
+ * This class is immutable.
+ */
+public final class PccId extends Identifier<IpAddress> {
+
+ private static final String SCHEME = "l3";
+ private static final long UNKNOWN = 0;
+
+ /**
+ * Private constructor.
+ */
+ private PccId(IpAddress ipAddress) {
+ super(ipAddress);
+ }
+
+ /**
+ * Create a PccId from ip address.
+ *
+ * @param ipAddress IP address
+ * @return ipAddress
+ */
+ public static PccId pccId(IpAddress ipAddress) {
+ return new PccId(ipAddress);
+ }
+
+ /**
+ * Returns the ip address.
+ *
+ * @return ipAddress
+ */
+ public IpAddress ipAddress() {
+ return identifier;
+ }
+
+ /**
+ * Returns PccId created from the given client URI.
+ *
+ * @param uri device URI
+ * @return pccid
+ */
+ public static PccId pccid(URI uri) {
+ checkArgument(uri.getScheme().equals(SCHEME), "Unsupported URI scheme");
+ return new PccId(IpAddress.valueOf(uri.getSchemeSpecificPart()));
+ }
+
+ /**
+ * Produces client URI from the given DPID.
+ *
+ * @param pccid client pccid
+ * @return client URI
+ */
+ public static URI uri(PccId pccid) {
+ return uri(pccid.ipAddress());
+ }
+
+ /**
+ * Produces client URI from the given ip address.
+ *
+ * @param ipAddress ip of client
+ * @return client URI
+ */
+ public static URI uri(IpAddress ipAddress) {
+ try {
+ return new URI(SCHEME, ipAddress.toString(), null);
+ } catch (URISyntaxException e) {
+ return null;
+ }
+ }
+}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepAnnotationKeys.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepAnnotationKeys.java
new file mode 100644
index 0000000..bdcd35a
--- /dev/null
+++ b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepAnnotationKeys.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2016-present Open Networking Foundation
+ *
+ * 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.server;
+
+/**
+ * Collection of keys for annotation for PCEP tunnels.
+ */
+public final class PcepAnnotationKeys {
+
+ /**
+ * Prohibits instantiation.
+ */
+ private PcepAnnotationKeys() {
+ }
+
+ /**
+ * Annotation key for bandwidth.
+ * The value for this key is interpreted as Mbps.
+ */
+ public static final String BANDWIDTH = "bandwidth";
+
+ /**
+ * Annotation key for the LSP signaling type.
+ */
+ public static final String LSP_SIG_TYPE = "lspSigType";
+
+ /**
+ * Annotation key for the PCC tunnel id.
+ */
+ public static final String PCC_TUNNEL_ID = "PccTunnelId";
+
+ /**
+ * Annotation key for the LSP id assigned per tunnel per session.
+ */
+ public static final String PLSP_ID = "PLspId";
+
+ /**
+ * Annotation key for the LSP id assigned per tunnel.
+ */
+ public static final String LOCAL_LSP_ID = "localLspId";
+
+ /**
+ * Annotation key for the identification of initiated LSP.
+ */
+ public static final String PCE_INIT = "pceInit";
+
+ /**
+ * Annotation key for the cost type.
+ */
+ public static final String COST_TYPE = "costType";
+
+ /**
+ * Annotation key for the Delegation.
+ * Whether LSPs are delegated or not
+ */
+ public static final String DELEGATE = "delegate";
+}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepCfg.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepCfg.java
new file mode 100644
index 0000000..af5debf
--- /dev/null
+++ b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepCfg.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2016-present Open Networking Foundation
+ *
+ * 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.server;
+
+/**
+ * PCEP peer state information.
+ */
+
+public interface PcepCfg {
+
+ State getState();
+
+ void setState(State state);
+
+ enum State {
+ /**
+ * Signifies that its just created.
+ */
+ INIT,
+
+ /**
+ * Signifies that only IP Address is configured.
+ */
+ OPENWAIT,
+
+ /**
+ * Signifies that only Autonomous System is configured.
+ */
+ KEEPWAIT,
+
+ /**
+ * Signifies that both IP and Autonomous System is configured.
+ */
+ ESTABLISHED,
+
+ /**
+ * Signifies that both IP and Autonomous System is down.
+ */
+ DOWN
+ }
+
+}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepClient.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepClient.java
new file mode 100644
index 0000000..cace76a
--- /dev/null
+++ b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepClient.java
@@ -0,0 +1,199 @@
+/*
+ * Copyright 2015-present Open Networking Foundation
+ *
+ * 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.server;
+
+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).
+ */
+public interface PcepClient {
+
+ /**
+ * Writes the message to the driver.
+ *
+ * @param msg the message to write
+ */
+ void sendMessage(PcepMessage msg);
+
+ /**
+ * Writes the PcepMessage list to the driver.
+ *
+ * @param msgs the messages to be written
+ */
+ void sendMessage(List<PcepMessage> msgs);
+
+ /**
+ * Handle a message from the pcc.
+ *
+ * @param fromClient the message to handle
+ */
+ void handleMessage(PcepMessage fromClient);
+
+ /**
+ * Provides the factory for this PCEP version.
+ *
+ * @return PCEP version specific factory.
+ */
+ PcepFactory factory();
+
+ /**
+ * Gets a string version of the ID for this pcc.
+ *
+ * @return string version of the ID
+ */
+ String getStringId();
+
+ /**
+ * Gets the ipAddress of the client.
+ *
+ * @return the client pccId in IPAddress format
+ */
+ PccId getPccId();
+
+ /**
+ * Checks if the pcc is still connected.
+ *
+ * @return true if client is connected, false otherwise
+ */
+ boolean isConnected();
+
+ /**
+ * Disconnects the pcc by closing the TCP connection. Results in a call
+ * to the channel handler's channelDisconnected method for cleanup.
+ */
+ void disconnectClient();
+
+ /**
+ * Indicates if this pcc is optical.
+ *
+ * @return true if optical
+ */
+ boolean isOptical();
+
+ /**
+ * Identifies the channel used to communicate with the pcc.
+ *
+ * @return string representation of the connection to the client
+ */
+ String channelId();
+
+ /**
+ * Sets the status of LSP state synchronization.
+ *
+ * @param syncStatus LSP synchronization status to be set
+ */
+ void setLspDbSyncStatus(PcepSyncStatus syncStatus);
+
+ /**
+ * Indicates the LSP state synchronization status of this pcc.
+ *
+ * @return LSP state synchronization status.
+ */
+ PcepSyncStatus lspDbSyncStatus();
+
+ /**
+ * Sets the status of label DB synchronization.
+ *
+ * @param syncStatus label DB synchronization status to be set
+ */
+ void setLabelDbSyncStatus(PcepSyncStatus syncStatus);
+
+ /**
+ * Indicates the label DB synchronization status of this pcc.
+ *
+ * @return label DB synchronization status.
+ */
+ PcepSyncStatus labelDbSyncStatus();
+
+ /**
+ * Sets capability negotiated during open message exchange.
+ *
+ * @param capability supported by client
+ */
+ void setCapability(ClientCapability capability);
+
+ /**
+ * Obtains capability supported by client.
+ *
+ * @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);
+}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepClientController.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepClientController.java
new file mode 100644
index 0000000..226944e
--- /dev/null
+++ b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepClientController.java
@@ -0,0 +1,177 @@
+/*
+ * Copyright 2015-present Open Networking Foundation
+ *
+ * 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.server;
+
+import org.onosproject.incubator.net.tunnel.DefaultLabelStack;
+import org.onosproject.incubator.net.tunnel.LabelStack;
+import org.onosproject.incubator.net.tunnel.Tunnel;
+import org.onosproject.net.Path;
+import org.onosproject.pcepio.protocol.PcepMessage;
+import org.onosproject.pcepio.types.PcepValueType;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Abstraction of an Pcep client controller. Serves as a one stop
+ * shop for obtaining Pcep devices and (un)register listeners
+ * on pcep events
+ */
+public interface PcepClientController {
+
+ /**
+ * Returns list of pcc clients connected to this Pcep controller.
+ *
+ * @return list of PcepClient elements
+ */
+ Collection<PcepClient> getClients();
+
+ /**
+ * Returns the actual pcc client for the given ip address.
+ *
+ * @param pccId the id of the pcc client to fetch
+ * @return the interface to this pcc client
+ */
+ PcepClient getClient(PccId pccId);
+
+ /**
+ * Register a listener for meta events that occur to pcep
+ * devices.
+ *
+ * @param listener the listener to notify
+ */
+ void addListener(PcepClientListener listener);
+
+ /**
+ * Unregister a listener.
+ *
+ * @param listener the listener to unregister
+ */
+ void removeListener(PcepClientListener listener);
+
+ /**
+ * Register a listener for PCEP msg events.
+ *
+ * @param listener the listener to notify
+ */
+ void addEventListener(PcepEventListener listener);
+
+ /**
+ * Unregister a listener.
+ *
+ * @param listener the listener to unregister
+ */
+ 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);
+
+ /**
+ * Send a message to a particular pcc client.
+ *
+ * @param pccId the id of the client to send message.
+ * @param msg the message to send
+ */
+ void writeMessage(PccId pccId, PcepMessage msg);
+
+ /**
+ * Process a message and notify the appropriate listeners.
+ *
+ * @param pccId id of the client the message arrived on
+ * @param msg the message to process.
+ */
+ void processClientMessage(PccId pccId, PcepMessage msg);
+
+ /**
+ * Close all connected PCC clients.
+ */
+ void closeConnectedClients();
+
+ /**
+ * Create label stack from the given path.
+ *
+ * @param path from which label stack is to be computed
+ * @return the label stack
+ */
+ public LabelStack computeLabelStack(Path path);
+
+ /**
+ * Allocates and downloads local labels for the given LSP.
+ *
+ * @param tunnel for which local labels have to be assigned and downloaded
+ * @return success or failure
+ */
+ public boolean allocateLocalLabel(Tunnel tunnel);
+
+ /**
+ * Creates label stack for ERO object from network resource.
+ *
+ * @param labelStack label stack
+ * @param path (hop list)
+ * @return list of ERO sub-objects
+ */
+ public LinkedList<PcepValueType> createPcepLabelStack(DefaultLabelStack labelStack, Path path);
+
+ /**
+ * Returns list of PCEP exceptions.
+ *
+ * @return PcepExceptions
+ */
+ public Map<String, List<String>> getPcepExceptions();
+
+ /**
+ * Returns all the pcep error messages received .
+ *
+ * @return PcepErrorMsg
+ */
+ public Map<Integer, Integer> getPcepErrorMsg();
+
+ /**
+ * Returns the pcep session details.
+ *
+ * @return PcepSession
+ */
+ public Map<String, String> getPcepSessionMap();
+
+ /**
+ * Returns the pcep sessionid information.
+ *
+ * @return PcepSessionId
+ */
+ public Map<String, Byte> getPcepSessionIdMap();
+
+ /**
+ * Creates detailed information about pcep error value and type per peer.
+ *
+ * @param peerId id of the peer which sent the error message
+ * @param errorType the error type of the error message received
+ * @param errValue the error value of the error message received
+ */
+ void peerErrorMsg(String peerId, Integer errorType, Integer errValue);
+}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepClientListener.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepClientListener.java
new file mode 100644
index 0000000..5a0d5bc
--- /dev/null
+++ b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepClientListener.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2015-present Open Networking Foundation
+ *
+ * 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.server;
+
+/**
+ * Allows for providers interested in PCC client events to be notified.
+ */
+public interface PcepClientListener {
+
+ /**
+ * Notify that the PCC was connected.
+ *
+ * @param pccId the id of the client that connected
+ */
+ void clientConnected(PccId pccId);
+
+ /**
+ * Notify that the PCC was disconnected.
+ *
+ * @param pccId the id of the client that disconnected.
+ */
+ void clientDisconnected(PccId pccId);
+}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepErrorDetail.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepErrorDetail.java
new file mode 100644
index 0000000..37ea6d0
--- /dev/null
+++ b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepErrorDetail.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2016-present Open Networking Foundation
+ *
+ * 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.server;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * PCEP error message details.
+ */
+public class PcepErrorDetail {
+
+ private Map<Integer, String> sessionEstablishmentFailureMap = new TreeMap<>();
+ private Map<Integer, String> unknownObjectMap = new TreeMap<>();
+ private Map<Integer, String> notSupportedObjectMap = new TreeMap<>();
+ private Map<Integer, String> policyViolationMap = new TreeMap<>();
+ private Map<Integer, String> mandatoryObjectMissingMap = new TreeMap<>();
+ private Map<Integer, String> receptionOfInvalidObjectMap = new TreeMap<>();
+ private Map<Integer, String> invalidOperationMap = new TreeMap<>();
+
+
+ public Map sessionEstablishmentFailure() {
+ sessionEstablishmentFailureMap.put(1, "Reception of an invalid Open message or a non Open message.");
+ sessionEstablishmentFailureMap.put(2, "no Open message received before the expiration of the OpenWait timer");
+ sessionEstablishmentFailureMap.put(3, "unacceptable and non-negotiable session characteristics");
+ sessionEstablishmentFailureMap.put(4, "unacceptable but negotiable session characteristics");
+ sessionEstablishmentFailureMap.put(5, "reception of a second Open message with still " +
+ "unacceptable session characteristics");
+ sessionEstablishmentFailureMap.put(6, "reception of a PCErr message proposing unacceptable " +
+ "session characteristics");
+ sessionEstablishmentFailureMap.put(7, "No Keepalive or PCErr message received before the " +
+ "expiration of the KeepWait timer");
+ sessionEstablishmentFailureMap.put(8, "PCEP version not supported");
+ return sessionEstablishmentFailureMap;
+ }
+
+
+ public Map unknownObject() {
+ unknownObjectMap.put(1, "Unrecognized object class");
+ unknownObjectMap.put(2, "Unrecognized object type");
+ return unknownObjectMap;
+ }
+
+ public Map notSupportedObject() {
+ notSupportedObjectMap.put(1, "Not Supported object class");
+ notSupportedObjectMap.put(2, "Not Supported object type");
+ return notSupportedObjectMap;
+ }
+
+
+ public Map policyViolation() {
+ policyViolationMap.put(1, "C bit of the METRIC object set (request rejected)");
+ policyViolationMap.put(2, "O bit of the RP object cleared (request rejected)");
+ return policyViolationMap;
+ }
+
+
+
+ public Map mandatoryObjectMissing() {
+ mandatoryObjectMissingMap.put(1, "RP object missing");
+ mandatoryObjectMissingMap.put(2, "RRO missing for a re-optimization request (R bit of the RP object set)");
+ mandatoryObjectMissingMap.put(2, "END-POINTS object missing");
+ return mandatoryObjectMissingMap;
+
+ }
+
+
+ public Map receptionOfInvalidObject() {
+ receptionOfInvalidObjectMap.put(1, "reception of an object with P flag not set although the P flag must be" +
+ "set according to this specification.");
+ return receptionOfInvalidObjectMap;
+ }
+
+ public Map invalidOperation() {
+ invalidOperationMap.put(1, "Attempted LSP Update Request for a non-delegated LSP. The PCEP-ERROR Object" +
+ " is followed by the LSP Object that identifies the LSP.");
+ invalidOperationMap.put(2, "Attempted LSP Update Request if the" +
+ " stateful PCE capability was not" +
+ " advertised.");
+ invalidOperationMap.put(3, "Attempted LSP Update Request for an LSP" +
+ "identified by an unknown PLSP-ID.");
+ invalidOperationMap.put(4, "A PCE indicates to a PCC that it has" +
+ " exceeded the resource limit allocated" +
+ " for its state, and thus it cannot" +
+ " accept and process its LSP State Report" +
+ " message.");
+ invalidOperationMap.put(5, "Attempted LSP State Report if active" +
+ " stateful PCE capability was not" +
+ " advertised.");
+ return invalidOperationMap;
+ }
+
+
+
+}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepErrorType.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepErrorType.java
new file mode 100644
index 0000000..8d51999
--- /dev/null
+++ b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepErrorType.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2016-present Open Networking Foundation
+ *
+ * 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.server;
+
+/**
+ * PCEP error message type information.
+ */
+public enum PcepErrorType {
+ SESSIONESTABLISHMENTFAILURE(1),
+ CAPABALITYNOTSUPPORTED(2),
+ UNKNOWNOBJECT(3),
+ NOTSUPPORTEDOBJECT(4),
+ POLICYVIOLATION(5),
+ MANDATORYOBJECTMISSING(6),
+ SYNCHRONIZEDPATHCOMPUTATIONREQUESTMISSING(7),
+ UNKNOWNREQUESTREFERENCE(8),
+ ESTABLISHINGSECONDPCEPSESSION(9),
+ RECEPTIONOFINVALIDOBJECT(10),
+ INVALIDOPERATION(19),
+ VIRTUALNETWORKTLVMISSING(255);
+
+ int value;
+
+ /**
+ * Creates an instance of Pcep Error Type.
+ *
+ * @param value represents Error type
+ */
+ PcepErrorType(int value) {
+ this.value = value;
+ }
+
+ /**
+ * Gets the value representing Pcep Error Type.
+ *
+ * @return value represents Error Type
+ */
+ public int value() {
+ return value;
+ }
+}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepEventListener.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepEventListener.java
new file mode 100644
index 0000000..06d49ed
--- /dev/null
+++ b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepEventListener.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2015-present Open Networking Foundation
+ *
+ * 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.server;
+
+import org.onosproject.incubator.net.tunnel.Tunnel;
+import org.onosproject.pcepio.protocol.PcepMessage;
+/**
+ * Notifies providers about PCEP message events.
+ */
+public interface PcepEventListener {
+
+ /**
+ * Handles the message event.
+ *
+ * @param pccId id of the pcc
+ * @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);
+}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepLspStatus.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepLspStatus.java
new file mode 100644
index 0000000..9ced00a
--- /dev/null
+++ b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepLspStatus.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2016-present Open Networking Foundation
+ *
+ * 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.server;
+
+import org.onosproject.incubator.net.tunnel.Tunnel.State;
+
+/**
+ * Representation of the PCEP LSP state.
+ */
+public enum PcepLspStatus {
+
+ /**
+ * Signifies that the LSP is not active.
+ */
+ DOWN,
+
+ /**
+ * Signifies that the LSP is signalled.
+ */
+ UP,
+
+ /**
+ * Signifies that the LSP is up and carrying traffic.
+ */
+ ACTIVE,
+
+ /**
+ * Signifies that the LSP is being torn down, resources are being released.
+ */
+ GOING_DOWN,
+
+ /**
+ * Signifies that the LSP is being signalled.
+ */
+ GOING_UP;
+
+ /**
+ * 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) {
+
+ switch (tunnelState) {
+
+ case INIT:
+ return PcepLspStatus.DOWN;
+
+ case ESTABLISHED:
+ return PcepLspStatus.GOING_UP;
+
+ case ACTIVE:
+ return PcepLspStatus.UP;
+
+ case FAILED: // fall through
+ case INACTIVE: // LSP is administratively down.
+ default:
+ return PcepLspStatus.DOWN;
+ }
+ }
+
+ /**
+ * 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) {
+
+ switch (lspState) {
+
+ case DOWN:
+ return State.FAILED;
+
+ case UP: // fall through
+ case ACTIVE:
+ return State.ACTIVE;
+
+ case GOING_DOWN:
+ return State.FAILED;
+
+ case GOING_UP:
+ return State.ESTABLISHED;
+
+ default:
+ return State.FAILED;
+ }
+ }
+}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepLspSyncAction.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepLspSyncAction.java
new file mode 100644
index 0000000..c120df3
--- /dev/null
+++ b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepLspSyncAction.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2016-present Open Networking Foundation
+ *
+ * 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.server;
+
+/**
+ * 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;
+ }
+}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepNodeListener.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepNodeListener.java
new file mode 100644
index 0000000..1bb0b95
--- /dev/null
+++ b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepNodeListener.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2016-present Open Networking Foundation
+ *
+ * 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.server;
+
+/**
+ * Notifies providers about PCEP node events.
+ */
+public interface PcepNodeListener {
+
+ /**
+ * Notifies that the node was added.
+ *
+ * @param pc PCEP client details
+ */
+ void addDevicePcepConfig(PcepClient pc);
+
+ /**
+ * Notifies that the node was removed.
+ *
+ * @param pccId PCEP client ID
+ */
+ void deleteDevicePcepConfig(PccId pccId);
+}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepPacketStats.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepPacketStats.java
new file mode 100644
index 0000000..5802cc5
--- /dev/null
+++ b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepPacketStats.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2015-present Open Networking Foundation
+ *
+ * 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.server;
+
+/**
+ * The representation for PCEP packet statistics.
+ */
+public interface PcepPacketStats {
+
+ /**
+ * Returns the count for no of packets sent out.
+ *
+ * @return int value of no of packets sent
+ */
+ int outPacketCount();
+
+ /**
+ * Returns the count for no of packets received.
+ *
+ * @return int value of no of packets sent
+ */
+ int inPacketCount();
+
+ /**
+ * Returns the count for no of wrong packets received.
+ *
+ * @return int value of no of wrong packets received
+ */
+ int wrongPacketCount();
+
+ /**
+ * Returns the time value.
+ *
+ * @return long value of time
+ */
+ long getTime();
+}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepSyncStatus.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepSyncStatus.java
new file mode 100644
index 0000000..e487b95
--- /dev/null
+++ b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepSyncStatus.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2016-present Open Networking Foundation
+ *
+ * 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.server;
+
+/**
+ * Representation of PCEP database sync status on session establishment.
+ */
+public enum PcepSyncStatus {
+
+ /**
+ * Specifies that the DB state is not synchronized.
+ */
+ NOT_SYNCED(0),
+
+ /**
+ * Specifies that the DB state is currently undergoing synchronization.
+ */
+ IN_SYNC(1),
+
+ /**
+ * Specifies that the DB state synchronization is completed.
+ */
+ SYNCED(2);
+
+ int value;
+
+ /**
+ * Assign val with the value as the sync status.
+ *
+ * @param val sync status
+ */
+ PcepSyncStatus(int val) {
+ value = val;
+ }
+}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/SrpIdGenerators.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/SrpIdGenerators.java
new file mode 100644
index 0000000..8d73287
--- /dev/null
+++ b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/SrpIdGenerators.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2016-present Open Networking Foundation
+ *
+ * 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.server;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.slf4j.Logger;
+
+/**
+ * Unique Srp Id generator for pcep messages.
+ */
+public final class SrpIdGenerators {
+
+ private static final Logger log = getLogger(SrpIdGenerators.class);
+ private static final AtomicInteger SRP_ID_GEN = new AtomicInteger();
+ private static final int MAX_SRP_ID = 0x7FFFFFFF;
+ private static int srpId;
+
+ /**
+ * Default constructor.
+ */
+ private SrpIdGenerators() {
+ }
+
+ /**
+ * Get the next srp id.
+ *
+ * @return srp id
+ */
+ public static int create() {
+ do {
+ if (srpId >= MAX_SRP_ID) {
+ if (SRP_ID_GEN.get() >= MAX_SRP_ID) {
+ SRP_ID_GEN.set(0);
+ }
+ }
+ srpId = SRP_ID_GEN.incrementAndGet();
+ } while (srpId > MAX_SRP_ID);
+ return srpId;
+ }
+}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/driver/PcepAgent.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/driver/PcepAgent.java
new file mode 100644
index 0000000..42f25cc
--- /dev/null
+++ b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/driver/PcepAgent.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2015-present Open Networking Foundation
+ *
+ * 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.server.driver;
+
+import org.onosproject.pcep.server.PccId;
+import org.onosproject.pcep.server.PcepClient;
+import org.onosproject.pcepio.protocol.PcepMessage;
+
+/**
+ * Responsible for keeping track of the current set Pcep clients
+ * connected to the system.
+ *
+ */
+public interface PcepAgent {
+
+ /**
+ * Add a pcc client that has just connected to the system.
+ *
+ * @param pccId the id of pcc client to add
+ * @param pc the actual pce client object.
+ * @return true if added, false otherwise.
+ */
+ boolean addConnectedClient(PccId pccId, PcepClient pc);
+
+ /**
+ * Checks if the activation for this pcc client is valid.
+ *
+ * @param pccId the id of pcc client to check
+ * @return true if valid, false otherwise
+ */
+ boolean validActivation(PccId pccId);
+
+ /**
+ * Clear all state in controller client maps for a pcc client that has
+ * disconnected from the local controller. Also release control for
+ * that pccIds client from the global repository. Notify client listeners.
+ *
+ * @param pccIds the id of pcc client to remove.
+ */
+ void removeConnectedClient(PccId pccIds);
+
+ /**
+ * Process a message coming from a pcc client.
+ *
+ * @param pccId the id of pcc client the message was received.
+ * @param m the message to process
+ */
+ 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);
+}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/driver/PcepClientDriver.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/driver/PcepClientDriver.java
new file mode 100644
index 0000000..58fc33f
--- /dev/null
+++ b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/driver/PcepClientDriver.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2015-present Open Networking Foundation
+ *
+ * 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.server.driver;
+
+import org.jboss.netty.channel.Channel;
+import org.onosproject.pcep.server.PccId;
+import org.onosproject.pcep.server.PcepClient;
+import org.onosproject.pcep.server.PcepPacketStats;
+import org.onosproject.pcepio.protocol.PcepVersion;
+
+
+/**
+ * Represents the driver side of an Path computation client(pcc).
+ *
+ */
+public interface PcepClientDriver extends PcepClient {
+
+ /**
+ * Sets the Pcep agent to be used. This method
+ * can only be called once.
+ *
+ * @param agent the agent to set.
+ */
+ void setAgent(PcepAgent agent);
+
+ /**
+ * Announce to the Pcep agent that this pcc client has connected.
+ *
+ * @return true if successful, false if duplicate switch.
+ */
+ boolean connectClient();
+
+ /**
+ * Remove this pcc client from the Pcep agent.
+ */
+ void removeConnectedClient();
+
+ /**
+ * Sets the PCEP version for this pcc.
+ *
+ * @param pcepVersion the version to set.
+ */
+ void setPcVersion(PcepVersion pcepVersion);
+
+ /**
+ * Sets the associated Netty channel for this pcc.
+ *
+ * @param channel the Netty channel
+ */
+ void setChannel(Channel channel);
+
+
+ /**
+ * Sets the keep alive time for this pcc.
+ *
+ * @param keepAliveTime the keep alive time to set.
+ */
+ void setPcKeepAliveTime(byte keepAliveTime);
+
+ /**
+ * Sets the dead time for this pcc.
+ *
+ * @param deadTime the dead timer value to set.
+ */
+ void setPcDeadTime(byte deadTime);
+
+ /**
+ * Sets the session id for this pcc.
+ *
+ * @param sessionId the session id value to set.
+ */
+ void setPcSessionId(byte sessionId);
+
+ /**
+ * Sets whether the pcc is connected.
+ *
+ * @param connected whether the pcc is connected
+ */
+ void setConnected(boolean connected);
+
+ /**
+ * Initializes the behavior.
+ *
+ * @param pccId id of pcc
+ * @param pcepVersion Pcep version
+ * @param pktStats Pcep Packet Stats
+ */
+ void init(PccId pccId, PcepVersion pcepVersion, PcepPacketStats pktStats);
+
+ /**
+ * Checks whether the handshake is complete.
+ *
+ * @return true is finished, false if not.
+ */
+ boolean isHandshakeComplete();
+
+}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/driver/PcepClientDriverFactory.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/driver/PcepClientDriverFactory.java
new file mode 100644
index 0000000..46e04ff
--- /dev/null
+++ b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/driver/PcepClientDriverFactory.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2015-present Open Networking Foundation
+ *
+ * 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.server.driver;
+
+import org.onlab.packet.IpAddress;
+import org.onosproject.pcepio.protocol.PcepVersion;
+
+/**
+ * Pcc Client factory which returns concrete pcc client objects for the
+ * physical pcc client in use.
+ *
+ */
+public interface PcepClientDriverFactory {
+
+
+ /**
+ * Constructs the real Pcep Client representation.
+ *
+ * @param pccIpAddress the ip address for this pcc client.
+ * @param pcepVersion the Pcep version in use
+ * @return the Pcep client representation.
+ */
+ PcepClientDriver getPcepClientImpl(IpAddress pccIpAddress,
+ PcepVersion pcepVersion);
+}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/driver/package-info.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/driver/package-info.java
new file mode 100644
index 0000000..6e542e7
--- /dev/null
+++ b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/driver/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2015-present Open Networking Foundation
+ *
+ * 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.
+ */
+
+/**
+ * PCEP client controller driver API.
+ */
+package org.onosproject.pcep.server.driver;
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/package-info.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/package-info.java
new file mode 100644
index 0000000..8ed1233
--- /dev/null
+++ b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2015-present Open Networking Foundation
+ *
+ * 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.
+ */
+
+/**
+ * PCEP client controller API.
+ */
+package org.onosproject.pcep.server;