Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 1 | package net.onrc.onos.intent; |
| 2 | |
| 3 | import net.floodlightcontroller.util.MACAddress; |
| 4 | import net.onrc.onos.ofcontroller.networkgraph.NetworkGraph; |
| 5 | import net.onrc.onos.ofcontroller.networkgraph.Port; |
| 6 | |
| 7 | /** |
| 8 | * @author Toshio Koide (t-koide@onlab.us) |
| 9 | */ |
| 10 | public class ShortestPathIntent extends Intent { |
| 11 | protected Port srcPort = null; |
| 12 | protected Port dstPort = null; |
| 13 | protected MACAddress srcMac = null; |
| 14 | protected MACAddress dstMac = null; |
| 15 | |
Toshio Koide | 13986d1 | 2014-02-11 20:25:32 -0800 | [diff] [blame^] | 16 | public ShortestPathIntent(String id, |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 17 | Port srcPort, MACAddress srcMac, |
| 18 | Port dstPort, MACAddress dstMac) { |
Toshio Koide | 13986d1 | 2014-02-11 20:25:32 -0800 | [diff] [blame^] | 19 | super(id); |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 20 | this.srcPort = srcPort; |
| 21 | this.dstPort = dstPort; |
| 22 | this.srcMac = srcMac; |
| 23 | this.dstMac = dstMac; |
| 24 | } |
| 25 | |
Toshio Koide | 13986d1 | 2014-02-11 20:25:32 -0800 | [diff] [blame^] | 26 | public ShortestPathIntent(NetworkGraph graph, String id, |
| 27 | long srcSwitch, long srcPort, long srcMac, |
| 28 | long dstSwitch, long dstPort, long dstMac) { |
| 29 | super(id); |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 30 | this.srcPort = graph.getSwitch(srcSwitch).getPort(srcPort); |
| 31 | this.dstPort = graph.getSwitch(dstSwitch).getPort(srcPort); |
| 32 | this.srcMac = MACAddress.valueOf(srcMac); |
| 33 | this.dstMac = MACAddress.valueOf(dstMac); |
| 34 | } |
| 35 | |
| 36 | public Port getSourcePort() { |
| 37 | return srcPort; |
| 38 | } |
| 39 | |
| 40 | public MACAddress getSourceMac() { |
| 41 | return srcMac; |
| 42 | } |
| 43 | |
| 44 | public Port getDestinationPort() { |
| 45 | return dstPort; |
| 46 | } |
| 47 | |
| 48 | public MACAddress getDestinationMac() { |
| 49 | return dstMac; |
| 50 | } |
| 51 | |
| 52 | @Override |
| 53 | public String toString() { |
| 54 | return String.format("srcPort:%s, srcMac:%s, dstPort:%s, dstMac:%s", |
| 55 | srcPort.toString(), srcMac.toString(), |
| 56 | dstPort.toString(), dstMac.toString()); |
| 57 | } |
| 58 | } |