blob: e7f1a1390a01f7fb3e7d91e936d5503277471464 [file] [log] [blame]
Toshio Koidead17d5e2014-02-11 11:36:02 -08001package net.onrc.onos.intent;
2
3import net.floodlightcontroller.util.MACAddress;
4import net.onrc.onos.ofcontroller.networkgraph.NetworkGraph;
5import net.onrc.onos.ofcontroller.networkgraph.Port;
6
7/**
8 * @author Toshio Koide (t-koide@onlab.us)
9 */
10public 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
16 public ShortestPathIntent(
17 Port srcPort, MACAddress srcMac,
18 Port dstPort, MACAddress dstMac) {
19 this.srcPort = srcPort;
20 this.dstPort = dstPort;
21 this.srcMac = srcMac;
22 this.dstMac = dstMac;
23 }
24
25 public ShortestPathIntent(NetworkGraph graph,
26 Long srcSwitch, Long srcPort, long srcMac,
27 Long dstSwitch, Long dstPort, long dstMac) {
28 this.srcPort = graph.getSwitch(srcSwitch).getPort(srcPort);
29 this.dstPort = graph.getSwitch(dstSwitch).getPort(srcPort);
30 this.srcMac = MACAddress.valueOf(srcMac);
31 this.dstMac = MACAddress.valueOf(dstMac);
32 }
33
34 public Port getSourcePort() {
35 return srcPort;
36 }
37
38 public MACAddress getSourceMac() {
39 return srcMac;
40 }
41
42 public Port getDestinationPort() {
43 return dstPort;
44 }
45
46 public MACAddress getDestinationMac() {
47 return dstMac;
48 }
49
50 @Override
51 public String toString() {
52 return String.format("srcPort:%s, srcMac:%s, dstPort:%s, dstMac:%s",
53 srcPort.toString(), srcMac.toString(),
54 dstPort.toString(), dstMac.toString());
55 }
56}