Add Intent class and its extended classes
- Intent class is an abstract class for the intents
- ShortestPathIntent class extends Intent class that expresses shortest hop between source-destination pair
- ConstrainedShortestPathIntent class extends ShortestPathIntent class that expresses bandwidth as an additional intention to ShortestPathIntent
- PathIntent class extends Intent class that expresses path
Change-Id: Ia5e8ddb55b333841d9eb438f9eb28866f6e3e300
diff --git a/src/main/java/net/onrc/onos/intent/ShortestPathIntent.java b/src/main/java/net/onrc/onos/intent/ShortestPathIntent.java
new file mode 100644
index 0000000..e7f1a13
--- /dev/null
+++ b/src/main/java/net/onrc/onos/intent/ShortestPathIntent.java
@@ -0,0 +1,56 @@
+package net.onrc.onos.intent;
+
+import net.floodlightcontroller.util.MACAddress;
+import net.onrc.onos.ofcontroller.networkgraph.NetworkGraph;
+import net.onrc.onos.ofcontroller.networkgraph.Port;
+
+/**
+ * @author Toshio Koide (t-koide@onlab.us)
+ */
+public class ShortestPathIntent extends Intent {
+ protected Port srcPort = null;
+ protected Port dstPort = null;
+ protected MACAddress srcMac = null;
+ protected MACAddress dstMac = null;
+
+ public ShortestPathIntent(
+ Port srcPort, MACAddress srcMac,
+ Port dstPort, MACAddress dstMac) {
+ this.srcPort = srcPort;
+ this.dstPort = dstPort;
+ this.srcMac = srcMac;
+ this.dstMac = dstMac;
+ }
+
+ public ShortestPathIntent(NetworkGraph graph,
+ Long srcSwitch, Long srcPort, long srcMac,
+ Long dstSwitch, Long dstPort, long dstMac) {
+ this.srcPort = graph.getSwitch(srcSwitch).getPort(srcPort);
+ this.dstPort = graph.getSwitch(dstSwitch).getPort(srcPort);
+ this.srcMac = MACAddress.valueOf(srcMac);
+ this.dstMac = MACAddress.valueOf(dstMac);
+ }
+
+ public Port getSourcePort() {
+ return srcPort;
+ }
+
+ public MACAddress getSourceMac() {
+ return srcMac;
+ }
+
+ public Port getDestinationPort() {
+ return dstPort;
+ }
+
+ public MACAddress getDestinationMac() {
+ return dstMac;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("srcPort:%s, srcMac:%s, dstPort:%s, dstMac:%s",
+ srcPort.toString(), srcMac.toString(),
+ dstPort.toString(), dstMac.toString());
+ }
+}