blob: b1f58f5d8e462253d62318cb3f29270b9e9bdda1 [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
Toshio Koide13986d12014-02-11 20:25:32 -080016 public ShortestPathIntent(String id,
Toshio Koidead17d5e2014-02-11 11:36:02 -080017 Port srcPort, MACAddress srcMac,
18 Port dstPort, MACAddress dstMac) {
Toshio Koide13986d12014-02-11 20:25:32 -080019 super(id);
Toshio Koidead17d5e2014-02-11 11:36:02 -080020 this.srcPort = srcPort;
21 this.dstPort = dstPort;
22 this.srcMac = srcMac;
23 this.dstMac = dstMac;
24 }
25
Toshio Koide13986d12014-02-11 20:25:32 -080026 public ShortestPathIntent(NetworkGraph graph, String id,
27 long srcSwitch, long srcPort, long srcMac,
28 long dstSwitch, long dstPort, long dstMac) {
29 super(id);
Toshio Koidead17d5e2014-02-11 11:36:02 -080030 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}