diff options
author | Ashlee Young <ashlee@onosfw.com> | 2015-09-09 22:15:21 -0700 |
---|---|---|
committer | Ashlee Young <ashlee@onosfw.com> | 2015-09-09 22:15:21 -0700 |
commit | 13d05bc8458758ee39cb829098241e89616717ee (patch) | |
tree | 22a4d1ce65f15952f07a3df5af4b462b4697cb3a /framework/src/onos/apps/pcep-api | |
parent | 6139282e1e93c2322076de4b91b1c85d0bc4a8b3 (diff) |
ONOS checkin based on commit tag e796610b1f721d02f9b0e213cf6f7790c10ecd60
Change-Id: Ife8810491034fe7becdba75dda20de4267bd15cd
Diffstat (limited to 'framework/src/onos/apps/pcep-api')
15 files changed, 1088 insertions, 0 deletions
diff --git a/framework/src/onos/apps/pcep-api/pom.xml b/framework/src/onos/apps/pcep-api/pom.xml new file mode 100644 index 00000000..80b4a436 --- /dev/null +++ b/framework/src/onos/apps/pcep-api/pom.xml @@ -0,0 +1,12 @@ +<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-apps</artifactId> + <version>1.3.0-SNAPSHOT</version> + </parent> + <artifactId>onos-app-pcep-api</artifactId> + <packaging>bundle</packaging> + + <description>PCEP protocol API</description> +</project>
\ No newline at end of file diff --git a/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepController.java b/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepController.java new file mode 100644 index 00000000..a14dcd12 --- /dev/null +++ b/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepController.java @@ -0,0 +1,122 @@ +/* + * Copyright 2015 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.api; + +import org.onosproject.net.DeviceId; + +/** + * Abstraction of an PCEP controller. Serves as a one stop shop for obtaining + * PCEP devices and (un)register listeners on PCEP events + */ +public interface PcepController { + + /** + * Returns all switches known to this PCEP controller. + * + * @return Iterable of did elements + */ + Iterable<PcepSwitch> getSwitches(); + + /** + * Return a switch with a specified did. + * + * @param did of a device + * @return a pcep device + */ + PcepSwitch getSwitch(PcepDpid did); + + /** + * Register a listener for meta events that occur to PCEP devices. + * + * @param listener the listener to notify + */ + void addListener(PcepSwitchListener listener); + + /** + * Unregister a listener. + * + * @param listener the listener to unregister + */ + void removeListener(PcepSwitchListener listener); + + /** + * Register a listener for meta events that occur to PCEP links. + * + * @param listener the listener to notify + */ + void addLinkListener(PcepLinkListener listener); + + /** + * Unregister a link listener. + * + * @param listener the listener to unregister + */ + void removeLinkListener(PcepLinkListener listener); + + /** + * Register a listener for meta events that occur to PCEP tunnel. + * + * @param listener the listener to notify + */ + void addTunnelListener(PcepTunnelListener listener); + + /** + * Unregister a tunnel listener. + * + * @param listener the listener to unregister + */ + void removeTunnelListener(PcepTunnelListener listener); + + /** + * Setup a tunnel through pcep controller. + * + * @param srcDid src deviceId of tunnel + * @param dstDid dst deviceId of tunnel + * @param srcPort src port + * @param dstPort dst port + * @param bandwidth andwidth of tunnel + * @param name tunnel name + * @return pcep tunnel + */ + PcepTunnel applyTunnel(DeviceId srcDid, DeviceId dstDid, + long srcPort, long dstPort, long bandwidth, + String name); + + /** + * Delete tunnel by id. + * + * @param id pcep tunnel id. + * @return true or false + */ + Boolean deleteTunnel(String id); + + /** + * Update tunnel bandwidth by tunnel id. + * + * @param id tunnel id + * @param bandwidth bandwidth of a tunnel + * @return true or false + */ + Boolean updateTunnelBandwidth(String id, long bandwidth); + + /** + * Send statistic request by tunnel id. + * + * @param pcepTunnelId PCEP tunnel id + */ + void getTunnelStatistics(String pcepTunnelId); + +} diff --git a/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepDpid.java b/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepDpid.java new file mode 100644 index 00000000..9d324e77 --- /dev/null +++ b/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepDpid.java @@ -0,0 +1,101 @@ +/* + * Copyright 2014 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.api; + +import java.net.URI; +import java.net.URISyntaxException; + +import org.onosproject.pcep.tools.PcepTools; + +/** + * The class representing a network switch PCEPDid. This class is immutable. + */ +public final class PcepDpid { + + private static final String SCHEME = "pcep"; + private static final long UNKNOWN = 0; + private long nodeId; + + /** + * Default constructor. + */ + public PcepDpid() { + this.nodeId = PcepDpid.UNKNOWN; + } + + /** + * Constructor from a long value. + * + * @param value long value for construct + */ + public PcepDpid(long value) { + this.nodeId = value; + } + + /** + * Constructor from a String. + * + * @param value string value for construct + */ + public PcepDpid(String value) { + this.nodeId = Long.parseLong(value, 16); + } + + /** + * Produces device URI from the given DPID. + * + * @param dpid device dpid + * @return device URI + */ + public static URI uri(PcepDpid dpid) { + return uri(dpid.nodeId); + } + + /** + * Produces device long from the given string which comes from the uri + * method. + * + * @param value string value which produced by uri method. + * @return a long value. + */ + public static long toLong(String value) { + return PcepTools.ipToLong(value.replace(SCHEME, "")); + } + + /** + * Produces device URI from the given DPID long. + * + * @param value device dpid as long + * @return device URI + */ + public static URI uri(long value) { + try { + return new URI(SCHEME, PcepTools.longToIp(value), null); + } catch (URISyntaxException e) { + return null; + } + } + + /** + * Return a device id with the form of long. + * + * @return long value + */ + public long value() { + return this.nodeId; + } + +} diff --git a/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepHopNodeDescription.java b/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepHopNodeDescription.java new file mode 100644 index 00000000..281f32f3 --- /dev/null +++ b/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepHopNodeDescription.java @@ -0,0 +1,62 @@ +/* + * Copyright 2015 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.api; + +/** + * Description of a pcep tunnel hop node.a hop list consists of a number of hop + * node. + */ +public class PcepHopNodeDescription { + private PcepDpid deviceId; + private long portNum; + + /** + * Get the pcepdpid of a node. + * + * @return device pcepdpid. + */ + public PcepDpid getDeviceId() { + return deviceId; + } + + /** + * Set the pcepdpid of a node. + * + * @param deviceId pcep dpid of a node. + */ + public void setDeviceId(PcepDpid deviceId) { + this.deviceId = deviceId; + } + + /** + * Get the port number of a node. + * + * @return port number. + */ + public long getPortNum() { + return portNum; + } + + /** + * Set the port number of a node. + * + * @param portNum port number of a node. + */ + public void setPortNum(long portNum) { + this.portNum = portNum; + } + +} diff --git a/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepLink.java b/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepLink.java new file mode 100644 index 00000000..4dc05de1 --- /dev/null +++ b/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepLink.java @@ -0,0 +1,136 @@ +/* + * Copyright 2015 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.api; + +import org.onosproject.net.Port; + +/** + * Abstraction of a network infrastructure link. + */ +public interface PcepLink extends PcepOperator { + + enum SubType { + /** + * Optical Transmission Section Link. + */ + OTS, + + /** + * Optical Physical Section Link. + */ + OPS, + + /** + * User-to-Network Interface Link. + */ + UNI, + + /** + * Optical channel Data Unit-k link. + */ + ODUk, + + /** + * Optical Transport Network link. + */ + OTU, + } + + + enum PortType { + ODU_PORT, OCH_PORT, OMS_PORT + } + + /** + * Returns the link endpoint port type. + * + * @return endpoint port type + */ + PortType portType(); + + /** + * Returns the link sub type,OTS,OPS,PKT_OPTICAL or ODUK. + * + * @return link subType + */ + + SubType linkSubType(); + + /** + * Returns the link state, up or down. + * + * @return link state + */ + String linkState(); + + /** + * Returns the distance of a link. + * + * @return distance + */ + int linkDistance(); + + /** + * Returns the capacity type of a link,1: WAVELENGTHNUM, 2:SLOTNUM, 3, + * BANDWIDTH. + * + * @return capacity type + */ + String linkCapacityType(); + + /** + * Returns the available capacity value ,such as available bandwidth. + * + * @return availValue + */ + int linkAvailValue(); + + /** + * Returns the max capacity value ,such as max bandwidth. + * + * @return maxValue + */ + int linkMaxValue(); + + /** + * Returns the source device did of a link. + * + * @return source did + */ + PcepDpid linkSrcDeviceID(); + + /** + * Returns the destination device did of a link. + * + * @return destination did + */ + PcepDpid linkDstDeviceId(); + + /** + * Returns the source port of a link. + * + * @return port number + */ + Port linkSrcPort(); + + /** + * Returns the destination port of a link. + * + * @return port number + */ + Port linkDstPort(); + +} diff --git a/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepLinkListener.java b/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepLinkListener.java new file mode 100644 index 00000000..608ef1bf --- /dev/null +++ b/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepLinkListener.java @@ -0,0 +1,30 @@ +/* + * Copyright 2015 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.api; + +/** + * Allows for providers interested in Link events to be notified. + */ +public interface PcepLinkListener { + + /** + * Notify that get a packet of link from network and need do some + * processing. + * + * @param link pcep link + */ + void handlePCEPlink(PcepLink link); +} diff --git a/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepOperator.java b/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepOperator.java new file mode 100644 index 00000000..452244da --- /dev/null +++ b/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepOperator.java @@ -0,0 +1,35 @@ +/* + * Copyright 2015 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.api; + +/** + * A interface defined operator type, and provide a method to get the operator + * type. + */ +public interface PcepOperator { + + enum OperationType { + + ADD, UPDATE, DELETE, + } + + /** + * Get operate type of a event,such as device add ,device update. + * + * @return operation type. + */ + OperationType getOperationType(); +} diff --git a/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepSwitch.java b/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepSwitch.java new file mode 100644 index 00000000..94f73dc3 --- /dev/null +++ b/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepSwitch.java @@ -0,0 +1,92 @@ +/* + * Copyright 2015 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.api; + +/* + * Represent to provider facing side of a switch + */ +public interface PcepSwitch extends PcepOperator { + + enum DeviceType { + /* optical device */ + ROADM, + + /* electronic device */ + OTN, + + /* router */ + ROUTER, + + /* unkown type */ + UNKNOW, + } + + /** + * Gets a string version of the ID for this switch. + * @return string version of the ID + */ + String getStringId(); + + /** + * Gets the datapathId of the switch. + * @return the switch dpid in long format + */ + long getId(); + + long getNeId(); + + /** + * Gets the sub type of the device. + * @return the sub type + */ + DeviceType getDeviceType(); + + /** + * fetch the manufacturer description. + * @return the description + */ + String manufacturerDescription(); + + /** + * fetch the datapath description. + * @return the description + */ + String datapathDescription(); + + /** + * fetch the hardware description. + * @return the description + */ + String hardwareDescription(); + + /** + * fetch the software description. + * @return the description + */ + String softwareDescription(); + + /** + * fetch the serial number. + * @return the serial + */ + String serialNumber(); + + /** + * Indicates if this switch is optical. + * @return true if optical + */ + boolean isOptical(); +} diff --git a/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepSwitchListener.java b/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepSwitchListener.java new file mode 100644 index 00000000..2017e739 --- /dev/null +++ b/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepSwitchListener.java @@ -0,0 +1,44 @@ +/* + * Copyright 2015 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.api; + +/** + * Notifies providers about switch in events. + */ +public interface PcepSwitchListener { + + /** + * Notify that the switch was added. + * + * @param dpid the switch where the event occurred + */ + void switchAdded(PcepDpid dpid); + + /** + * Notify that the switch was removed. + * + * @param dpid the switch where the event occurred. + */ + void switchRemoved(PcepDpid dpid); + + /** + * Notify that the switch has changed in some way. + * + * @param dpid the switch that changed + */ + void switchChanged(PcepDpid dpid); + +} diff --git a/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepTunnel.java b/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepTunnel.java new file mode 100644 index 00000000..6b0a7e69 --- /dev/null +++ b/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepTunnel.java @@ -0,0 +1,191 @@ +/* + * Copyright 2015 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.api; + +import java.util.List; + +/** + * Abstraction of a generalized PCEP Tunnel entity (bandwidth pipe) for L2 + * networks or L1/L0 networks, representation of e.g., VLAN, L1 ODUk connection, + * WDM OCH, etc.. + */ +public interface PcepTunnel extends PcepOperator { + + /** + * Describe the type of a tunnel. + */ + enum Type { + + /** + * Signifies that this is a L0 OCH tunnel. + */ + OCH, + + /** + * Signifies that this is a L1 OTN tunnel. + */ + OTN, + + /** + * Signifies that this is a L2 tunnel. + */ + UNI, + } + + /** + * The ability of a tunnel. + */ + enum Ability { + /** + * no protected tunnel,if the tunnel is broken ,then the user is out of + * service. + */ + NOPROTECTED, + + /** + * tunnel with rerouter ability.if a tunnel is broken, the tunnel will + * try to find another path to provider service. + */ + SILVER, + + /** + * tunnel with 1 + 1 rerouter ability.if a tunnel is broken, there'll be + * another tunnel providing service at once. + */ + DIAMOND + } + + enum PATHTYPE { + + /** + * Indicates path is the preferred path. + */ + FIRST, + + /** + * Indicates path is the alternate path. + */ + SECOND + } + + /** + * Represents state of the path, work normally or broken down. + */ + enum PathState { + NORMAL, BROKEN + } + + /** + * Returns the type of a tunnel. + * + * @return tunnel type + */ + Type type(); + + /** + * Returns the name of a tunnel. + * + * @return tunnel name + */ + String name(); + + /** + * Returns the device id of destination endpoint of a tunnel. + * + * @return device id + */ + PcepDpid srcDeviceID(); + + /** + * Returns the device id of source endpoint of a tunnel. + * + * @return device id + */ + PcepDpid dstDeviceId(); + + /** + * Returns source port of a tunnel. + * + * @return port number + */ + long srcPort(); + + /** + * Returns destination port of a tunnel. + * + * @return port number + */ + long dstPort(); + + /** + * Returns the bandwidth of a tunnel. + * + * @return bandwidth + */ + long bandWidth(); + + /** + * Returns the tunnel id. + * + * @return id of the PCEP tunnel + */ + long id(); + + /** + * Returns the detail hop list of a tunnel. + * + * @return hop list + */ + List<PcepHopNodeDescription> getHopList(); + + /** + * Returns the instance of a pcep tunnel,a instance is used to mark the times of + * a tunnel created. instance and id identify a tunnel together. + * + * @return the instance of a tunnel. + */ + int getInstance(); + + /** + * Returns the state of a path. + * + * @return normal or broken + */ + PathState getPathState(); + + /** + * Returns the ability of a tunnel. + * + * @return ability of the tunenl + */ + Ability getSla(); + + /** + * Returns the path type of a path if the tunnel's ability is diamond . + * + * @return the type of a path, the preferred or alternate. + */ + PATHTYPE getPathType(); + + /** + * Get the under lay tunnel id of VLAN tunnel. + * + * @return the tunnel id of a OCH tunnel under lay of a VLAN tunnel. + */ + long underlayTunnelId(); + +} diff --git a/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepTunnelListener.java b/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepTunnelListener.java new file mode 100644 index 00000000..8b64b923 --- /dev/null +++ b/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepTunnelListener.java @@ -0,0 +1,40 @@ +/* + * Copyright 2015 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.api; + +/** + * Allows for providers interested in tunnel events to be notified. + */ +public interface PcepTunnelListener { + + /** + * Notify that get a packet of tunnel from network and need do some + * processing. + * + * @param tunnel a pceptunnel. + */ + void handlePCEPTunnel(PcepTunnel tunnel); + + /** + * Notify that get a tunnel statistic data from the network. + * + * @param tunnelStatistics tunnel statistic information. + */ + void handlePcepTunnelStatistics(PcepTunnelStatistics tunnelStatistics); + + + +} diff --git a/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepTunnelStatistics.java b/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepTunnelStatistics.java new file mode 100644 index 00000000..20ed00e3 --- /dev/null +++ b/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepTunnelStatistics.java @@ -0,0 +1,65 @@ +/* + * + * * Copyright 2015 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.api; + +import java.time.Duration; +import java.util.List; + +/** + * Statistics of a PCEP tunnel. + */ +public interface PcepTunnelStatistics { + + + /** + * Returns the id of PCEP tunnel. + * + * @return PCEP tunnel id + */ + long id(); + + + /** + * Returns the bandwidth utilization of a PCEP tunnel. + * + * @return PCEP bandwidth utilization + */ + double bandwidthUtilization(); + + /** + * Returns the flow loss rate of a tunnel. + * + * @return tunnel flow loss rate + */ + double packetLossRate(); + + /** + * Returns the end-to-end traffic flow delay of a tunnel. + * + * @return tunnel traffic flow delay + */ + Duration flowDelay(); + + /** + * Returns the alarms on a tunnel. + * + * @return tunnel alarms + */ + List<String> alarms(); +} diff --git a/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/package-info.java b/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/package-info.java new file mode 100644 index 00000000..61c8290d --- /dev/null +++ b/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/api/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2015 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. + */ + +/** + * PCEP controller API. + */ +package org.onosproject.pcep.api;
\ No newline at end of file diff --git a/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/tools/PcepTools.java b/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/tools/PcepTools.java new file mode 100644 index 00000000..28eaebdd --- /dev/null +++ b/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/tools/PcepTools.java @@ -0,0 +1,119 @@ +/* + * Copyright 2015 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.tools; + +import javax.xml.bind.DatatypeConverter; + +/** + * tools fo pcep app. + */ +public abstract class PcepTools { + + private PcepTools() { + + } + + /** + * Converts decimal byte array to a hex string. + * + * @param byteArray byte array + * @return a hex string + */ + public static String toHexString(byte[] byteArray) { + return DatatypeConverter.printHexBinary(byteArray); + } + + /** + * Converts a hex string to a decimal byte array. + * + * @param hexString a hex string + * @return byte array + */ + public static byte[] toByteArray(String hexString) { + return DatatypeConverter.parseHexBinary(hexString); + } + + /** + * Converts a byte array to a decimal string. + * + * @param bytes a byte array + * @return a decimal string + */ + public static String toDecimalString(byte[] bytes) { + String str = ""; + for (int i = 0; i < bytes.length; i++) { + str += String.valueOf(bytes[i]); + } + return str; + } + + /** + * convert a string to the form of ip address. + * + * @param str a string + * @return a string with ip format + */ + public static String stringToIp(String str) { + long ipInt = Long.parseLong(str, 16); + return longToIp(ipInt); + } + + /** + * convert a long to ip format. + * + * @param ipLong a decimal number. + * @return a ip format string + */ + public static String longToIp(long ipLong) { + StringBuilder sb = new StringBuilder(); + sb.append((ipLong >> 24) & 0xFF).append("."); + sb.append((ipLong >> 16) & 0xFF).append("."); + sb.append((ipLong >> 8) & 0xFF).append("."); + sb.append(ipLong & 0xFF); + return sb.toString(); + } + + /** + * convert a string with ip format to a long. + * + * @param strIp a string with ip format + * @return a long number + */ + public static long ipToLong(String strIp) { + long[] ip = new long[4]; + int position1 = strIp.indexOf("."); + int position2 = strIp.indexOf(".", position1 + 1); + int position3 = strIp.indexOf(".", position2 + 1); + ip[0] = Long.parseLong(strIp.substring(0, position1)); + ip[1] = Long.parseLong(strIp.substring(position1 + 1, position2)); + ip[2] = Long.parseLong(strIp.substring(position2 + 1, position3)); + ip[3] = Long.parseLong(strIp.substring(position3 + 1)); + return (ip[0] << 24) + (ip[1] << 16) + (ip[2] << 8) + ip[3]; + } + + /** + * get a integer value from a cut string. + * + * @param str a whole string + * @param base cut the string from this index + * @param offset the offset when execute the cut + * @return a integer value + */ + public static int tranferHexStringToInt(String str, int base, int offset) { + return Integer.parseInt(str.substring(base, offset), 16); + + } +} diff --git a/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/tools/package-info.java b/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/tools/package-info.java new file mode 100644 index 00000000..8358a45f --- /dev/null +++ b/framework/src/onos/apps/pcep-api/src/main/java/org/onosproject/pcep/tools/package-info.java @@ -0,0 +1,19 @@ +/* + * Copyright 2015 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. + */ +/** + * tools for pcep app. + */ +package org.onosproject.pcep.tools;
\ No newline at end of file |