blob: 660cb7cf1ba93c70b254e05e9cea1dde8e0bf599 [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;
TeruU30c0c932014-05-15 16:47:41 -070017 protected int idleTimeout;
18 protected int hardTimeout;
19 protected int firstSwitchIdleTimeout;
20 protected int firstSwitchHardTimetout;
Toshio Koidead17d5e2014-02-11 11:36:02 -080021
Ray Milkey269ffb92014-04-03 14:43:30 -070022 /**
Ray Milkeyb41100a2014-04-10 10:42:15 -070023 * Default constructor for Kryo deserialization.
Ray Milkey269ffb92014-04-03 14:43:30 -070024 */
25 protected ShortestPathIntent() {
26 }
Toshio Koidead17d5e2014-02-11 11:36:02 -080027
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070028 /**
29 * Constructor for ShortestPathIntent.
30 *
31 * @param id Intent ID
32 * @param srcSwitch Source Switch DPID
33 * @param srcPort Source Port
34 * @param srcMac Source Host MAC Address
35 * @param dstSwitch Destination Switch DPID
36 * @param dstPort Destination Port
37 * @param dstMac Destination Host MAC Address
38 */
Ray Milkey269ffb92014-04-03 14:43:30 -070039 public ShortestPathIntent(String id,
40 long srcSwitch, long srcPort, long srcMac,
41 long dstSwitch, long dstPort, long dstMac) {
42 super(id);
43 srcSwitchDpid = srcSwitch;
44 srcPortNumber = srcPort;
45 srcMacAddress = srcMac;
46 dstSwitchDpid = dstSwitch;
47 dstPortNumber = dstPort;
48 dstMacAddress = dstMac;
49 }
Toshio Koidead17d5e2014-02-11 11:36:02 -080050
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070051 /**
52 * Gets the source Switch DPID.
53 *
54 * @return Source Switch DPID
55 */
Ray Milkey269ffb92014-04-03 14:43:30 -070056 public long getSrcSwitchDpid() {
57 return srcSwitchDpid;
58 }
Toshio Koidead17d5e2014-02-11 11:36:02 -080059
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070060 /**
61 * Gets the source Port.
62 *
63 * @return Source Port
64 */
Ray Milkey269ffb92014-04-03 14:43:30 -070065 public long getSrcPortNumber() {
66 return srcPortNumber;
67 }
Toshio Koidead17d5e2014-02-11 11:36:02 -080068
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070069 /**
70 * Gets the source Host MAC Address.
71 *
72 * @return Source Host MAC Address
73 */
Ray Milkey269ffb92014-04-03 14:43:30 -070074 public long getSrcMac() {
75 return srcMacAddress;
76 }
Toshio Koidead17d5e2014-02-11 11:36:02 -080077
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070078 /**
79 * Gets the destination Switch DPID.
80 *
81 * @return Destination Switch DPID
82 */
Ray Milkey269ffb92014-04-03 14:43:30 -070083 public long getDstSwitchDpid() {
84 return dstSwitchDpid;
85 }
Toshio Koide0e4d8d22014-02-14 10:56:10 -080086
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070087 /**
88 * Gets the destination Port.
89 *
90 * @return Destination Port
91 */
Ray Milkey269ffb92014-04-03 14:43:30 -070092 public long getDstPortNumber() {
93 return dstPortNumber;
94 }
Toshio Koide0e4d8d22014-02-14 10:56:10 -080095
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070096 /**
97 * Gets the destination Host MAC Address.
98 *
99 * @return Destination Host MAC Address
100 */
Ray Milkey269ffb92014-04-03 14:43:30 -0700101 public long getDstMac() {
102 return dstMacAddress;
103 }
Toshio Koidead17d5e2014-02-11 11:36:02 -0800104
Ray Milkey269ffb92014-04-03 14:43:30 -0700105 public void setPathIntent(PathIntent pathIntent) {
106 pathIntentId = pathIntent.getId();
107 }
Toshio Koidea10c0372014-02-20 17:28:10 -0800108
Ray Milkey269ffb92014-04-03 14:43:30 -0700109 public String getPathIntentId() {
110 return pathIntentId;
111 }
Toshio Koidea10c0372014-02-20 17:28:10 -0800112
TeruU30c0c932014-05-15 16:47:41 -0700113 @Deprecated
114 public int getIdleTimeout() {
115 return idleTimeout;
116 }
117
118 @Deprecated
119 public int getHardTimeout() {
120 return hardTimeout;
121 }
122
123 @Deprecated
124 public void setIdleTimeout(int idleTimeout) {
125 this.idleTimeout = idleTimeout;
126 }
127
128 @Deprecated
129 public void setHardTimeout(int hardTimeout) {
130 this.hardTimeout = hardTimeout;
131 }
132
133 @Deprecated
134 public int getFirstSwitchIdleTimeout() {
135 return firstSwitchIdleTimeout;
136 }
137
138 @Deprecated
139 public int getFirstSwitchHardTimetout() {
140 return firstSwitchHardTimetout;
141 }
142
143 @Deprecated
144 public void setFirstSwitchIdleTimeout(int firstSwitchIdleTimeout) {
145 this.firstSwitchIdleTimeout = firstSwitchIdleTimeout;
146 }
147
148 @Deprecated
149 public void setFirstSwitchHardTimetout(int firstSwitchHardTimetout) {
150 this.firstSwitchHardTimetout = firstSwitchHardTimetout;
151 }
152
Ray Milkey269ffb92014-04-03 14:43:30 -0700153 @Override
Pavlin Radoslavov7fb16412014-04-11 18:45:19 -0700154 public int hashCode() {
155 // TODO: Is this the intended behavior?
156 return (super.hashCode());
157 }
158
159 @Override
160 public boolean equals(Object obj) {
161 // TODO: Is this the intended behavior?
162 return (super.equals(obj));
163 }
164
165 @Override
Ray Milkey269ffb92014-04-03 14:43:30 -0700166 public String toString() {
167 return String.format("id:%s, state:%s, srcDpid:%s, srcPort:%d, srcMac:%s, dstDpid:%s, dstPort:%d, dstMac:%s",
168 getId(), getState(),
169 new Dpid(srcSwitchDpid), srcPortNumber, MACAddress.valueOf(srcMacAddress),
170 new Dpid(dstSwitchDpid), dstPortNumber, MACAddress.valueOf(dstMacAddress));
171 }
Toshio Koidead17d5e2014-02-11 11:36:02 -0800172}