blob: 94f3f36201e487b9f5e936e17477353d3cdae8b9 [file] [log] [blame]
Jonathan Hartaa380972014-04-03 10:24:46 -07001package net.onrc.onos.core.intent;
Toshio Koidead17d5e2014-02-11 11:36:02 -08002
3import net.floodlightcontroller.util.MACAddress;
Jonathan Hart23701d12014-04-03 10:45:48 -07004import net.onrc.onos.core.util.Dpid;
Toshio Koidead17d5e2014-02-11 11:36:02 -08005
6/**
7 * @author Toshio Koide (t-koide@onlab.us)
8 */
9public class ShortestPathIntent extends Intent {
Ray Milkey269ffb92014-04-03 14:43:30 -070010 protected long srcSwitchDpid;
11 protected long srcPortNumber;
12 protected long srcMacAddress;
13 protected long dstSwitchDpid;
14 protected long dstPortNumber;
15 protected long dstMacAddress;
16 protected String pathIntentId = null;
Toshio Koidead17d5e2014-02-11 11:36:02 -080017
Ray Milkey269ffb92014-04-03 14:43:30 -070018 /**
Ray Milkeyb41100a2014-04-10 10:42:15 -070019 * Default constructor for Kryo deserialization.
Ray Milkey269ffb92014-04-03 14:43:30 -070020 */
21 protected ShortestPathIntent() {
22 }
Toshio Koidead17d5e2014-02-11 11:36:02 -080023
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070024 /**
25 * Constructor for ShortestPathIntent.
26 *
27 * @param id Intent ID
28 * @param srcSwitch Source Switch DPID
29 * @param srcPort Source Port
30 * @param srcMac Source Host MAC Address
31 * @param dstSwitch Destination Switch DPID
32 * @param dstPort Destination Port
33 * @param dstMac Destination Host MAC Address
34 */
Ray Milkey269ffb92014-04-03 14:43:30 -070035 public ShortestPathIntent(String id,
36 long srcSwitch, long srcPort, long srcMac,
37 long dstSwitch, long dstPort, long dstMac) {
38 super(id);
39 srcSwitchDpid = srcSwitch;
40 srcPortNumber = srcPort;
41 srcMacAddress = srcMac;
42 dstSwitchDpid = dstSwitch;
43 dstPortNumber = dstPort;
44 dstMacAddress = dstMac;
45 }
Toshio Koidead17d5e2014-02-11 11:36:02 -080046
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070047 /**
48 * Gets the source Switch DPID.
49 *
50 * @return Source Switch DPID
51 */
Ray Milkey269ffb92014-04-03 14:43:30 -070052 public long getSrcSwitchDpid() {
53 return srcSwitchDpid;
54 }
Toshio Koidead17d5e2014-02-11 11:36:02 -080055
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070056 /**
57 * Gets the source Port.
58 *
59 * @return Source Port
60 */
Ray Milkey269ffb92014-04-03 14:43:30 -070061 public long getSrcPortNumber() {
62 return srcPortNumber;
63 }
Toshio Koidead17d5e2014-02-11 11:36:02 -080064
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070065 /**
66 * Gets the source Host MAC Address.
67 *
68 * @return Source Host MAC Address
69 */
Ray Milkey269ffb92014-04-03 14:43:30 -070070 public long getSrcMac() {
71 return srcMacAddress;
72 }
Toshio Koidead17d5e2014-02-11 11:36:02 -080073
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070074 /**
75 * Gets the destination Switch DPID.
76 *
77 * @return Destination Switch DPID
78 */
Ray Milkey269ffb92014-04-03 14:43:30 -070079 public long getDstSwitchDpid() {
80 return dstSwitchDpid;
81 }
Toshio Koide0e4d8d22014-02-14 10:56:10 -080082
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070083 /**
84 * Gets the destination Port.
85 *
86 * @return Destination Port
87 */
Ray Milkey269ffb92014-04-03 14:43:30 -070088 public long getDstPortNumber() {
89 return dstPortNumber;
90 }
Toshio Koide0e4d8d22014-02-14 10:56:10 -080091
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070092 /**
93 * Gets the destination Host MAC Address.
94 *
95 * @return Destination Host MAC Address
96 */
Ray Milkey269ffb92014-04-03 14:43:30 -070097 public long getDstMac() {
98 return dstMacAddress;
99 }
Toshio Koidead17d5e2014-02-11 11:36:02 -0800100
Ray Milkey269ffb92014-04-03 14:43:30 -0700101 public void setPathIntent(PathIntent pathIntent) {
102 pathIntentId = pathIntent.getId();
103 }
Toshio Koidea10c0372014-02-20 17:28:10 -0800104
Ray Milkey269ffb92014-04-03 14:43:30 -0700105 public String getPathIntentId() {
106 return pathIntentId;
107 }
Toshio Koidea10c0372014-02-20 17:28:10 -0800108
Ray Milkey269ffb92014-04-03 14:43:30 -0700109 @Override
Pavlin Radoslavov7fb16412014-04-11 18:45:19 -0700110 public int hashCode() {
111 // TODO: Is this the intended behavior?
112 return (super.hashCode());
113 }
114
115 @Override
116 public boolean equals(Object obj) {
117 // TODO: Is this the intended behavior?
118 return (super.equals(obj));
119 }
120
121 @Override
Ray Milkey269ffb92014-04-03 14:43:30 -0700122 public String toString() {
123 return String.format("id:%s, state:%s, srcDpid:%s, srcPort:%d, srcMac:%s, dstDpid:%s, dstPort:%d, dstMac:%s",
124 getId(), getState(),
125 new Dpid(srcSwitchDpid), srcPortNumber, MACAddress.valueOf(srcMacAddress),
126 new Dpid(dstSwitchDpid), dstPortNumber, MACAddress.valueOf(dstMacAddress));
127 }
Toshio Koidead17d5e2014-02-11 11:36:02 -0800128}