blob: 5c4e961fa6a0a5f08c8791e45a422225b3b373ee [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;
Ray Milkey2fa6ca42014-06-13 15:38:20 -07004import net.onrc.onos.core.topology.web.serializers.ShortestPathIntentSerializer;
Jonathan Hart23701d12014-04-03 10:45:48 -07005import net.onrc.onos.core.util.Dpid;
Ray Milkey2fa6ca42014-06-13 15:38:20 -07006import org.codehaus.jackson.map.annotate.JsonSerialize;
Toshio Koidead17d5e2014-02-11 11:36:02 -08007
8/**
9 * @author Toshio Koide (t-koide@onlab.us)
10 */
Ray Milkey2fa6ca42014-06-13 15:38:20 -070011@JsonSerialize(using = ShortestPathIntentSerializer.class)
Toshio Koidead17d5e2014-02-11 11:36:02 -080012public class ShortestPathIntent extends Intent {
Komal Shah399a2922014-05-28 01:57:40 -070013 public static final long EMPTYMACADDRESS = 0;
14 public static final int EMPTYIPADDRESS = 0;
Ray Milkey269ffb92014-04-03 14:43:30 -070015 protected long srcSwitchDpid;
16 protected long srcPortNumber;
17 protected long srcMacAddress;
18 protected long dstSwitchDpid;
19 protected long dstPortNumber;
20 protected long dstMacAddress;
Komal Shah399a2922014-05-28 01:57:40 -070021 protected int srcIpAddress;
22 protected int dstIpAddress;
Ray Milkey269ffb92014-04-03 14:43:30 -070023 protected String pathIntentId = null;
TeruU30c0c932014-05-15 16:47:41 -070024 protected int idleTimeout;
25 protected int hardTimeout;
26 protected int firstSwitchIdleTimeout;
Jonathan Hart4dc8d872014-05-30 14:23:25 -070027 protected int firstSwitchHardTimeout;
Toshio Koidead17d5e2014-02-11 11:36:02 -080028
Ray Milkey269ffb92014-04-03 14:43:30 -070029 /**
Ray Milkeyb41100a2014-04-10 10:42:15 -070030 * Default constructor for Kryo deserialization.
Ray Milkey269ffb92014-04-03 14:43:30 -070031 */
32 protected ShortestPathIntent() {
33 }
Toshio Koidead17d5e2014-02-11 11:36:02 -080034
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070035 /**
36 * Constructor for ShortestPathIntent.
37 *
38 * @param id Intent ID
39 * @param srcSwitch Source Switch DPID
40 * @param srcPort Source Port
41 * @param srcMac Source Host MAC Address
42 * @param dstSwitch Destination Switch DPID
43 * @param dstPort Destination Port
44 * @param dstMac Destination Host MAC Address
45 */
Ray Milkey269ffb92014-04-03 14:43:30 -070046 public ShortestPathIntent(String id,
47 long srcSwitch, long srcPort, long srcMac,
48 long dstSwitch, long dstPort, long dstMac) {
Komal Shah399a2922014-05-28 01:57:40 -070049 //super(id);
50 this(id, srcSwitch, srcPort, srcMac, EMPTYIPADDRESS, dstSwitch, dstPort, dstMac, EMPTYIPADDRESS);
51 }
52
53 // CHECKSTYLE:OFF suppress the warning about too many parameters
54 public ShortestPathIntent(String id,
55 long srcSwitch, long srcPort, long srcMac, int srcIp,
56 long dstSwitch, long dstPort, long dstMac, int dstIp ) {
57 // CHECKSTYLE:ON
Ray Milkey269ffb92014-04-03 14:43:30 -070058 super(id);
Komal Shah399a2922014-05-28 01:57:40 -070059 this.srcSwitchDpid = srcSwitch;
60 this.srcPortNumber = srcPort;
61 this.srcMacAddress = srcMac;
62 this.dstSwitchDpid = dstSwitch;
63 this.dstPortNumber = dstPort;
64 this.dstMacAddress = dstMac;
65 this.srcIpAddress = srcIp;
66 this.dstIpAddress = dstIp;
Ray Milkey269ffb92014-04-03 14:43:30 -070067 }
Toshio Koidead17d5e2014-02-11 11:36:02 -080068
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070069 /**
70 * Gets the source Switch DPID.
71 *
72 * @return Source Switch DPID
73 */
Ray Milkey269ffb92014-04-03 14:43:30 -070074 public long getSrcSwitchDpid() {
75 return srcSwitchDpid;
76 }
Toshio Koidead17d5e2014-02-11 11:36:02 -080077
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070078 /**
79 * Gets the source Port.
80 *
81 * @return Source Port
82 */
Ray Milkey269ffb92014-04-03 14:43:30 -070083 public long getSrcPortNumber() {
84 return srcPortNumber;
85 }
Toshio Koidead17d5e2014-02-11 11:36:02 -080086
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070087 /**
88 * Gets the source Host MAC Address.
89 *
90 * @return Source Host MAC Address
91 */
Ray Milkey269ffb92014-04-03 14:43:30 -070092 public long getSrcMac() {
93 return srcMacAddress;
94 }
Toshio Koidead17d5e2014-02-11 11:36:02 -080095
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070096 /**
97 * Gets the destination Switch DPID.
98 *
99 * @return Destination Switch DPID
100 */
Ray Milkey269ffb92014-04-03 14:43:30 -0700101 public long getDstSwitchDpid() {
102 return dstSwitchDpid;
103 }
Toshio Koide0e4d8d22014-02-14 10:56:10 -0800104
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -0700105 /**
106 * Gets the destination Port.
107 *
108 * @return Destination Port
109 */
Ray Milkey269ffb92014-04-03 14:43:30 -0700110 public long getDstPortNumber() {
111 return dstPortNumber;
112 }
Toshio Koide0e4d8d22014-02-14 10:56:10 -0800113
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -0700114 /**
115 * Gets the destination Host MAC Address.
116 *
117 * @return Destination Host MAC Address
118 */
Ray Milkey269ffb92014-04-03 14:43:30 -0700119 public long getDstMac() {
120 return dstMacAddress;
121 }
Toshio Koidead17d5e2014-02-11 11:36:02 -0800122
Ray Milkey269ffb92014-04-03 14:43:30 -0700123 public void setPathIntent(PathIntent pathIntent) {
124 pathIntentId = pathIntent.getId();
125 }
Toshio Koidea10c0372014-02-20 17:28:10 -0800126
Ray Milkey269ffb92014-04-03 14:43:30 -0700127 public String getPathIntentId() {
128 return pathIntentId;
129 }
Toshio Koidea10c0372014-02-20 17:28:10 -0800130
Ray Milkeyff735142014-05-22 19:06:02 -0700131 // TODO - this is intended to be refactored and removed
TeruU30c0c932014-05-15 16:47:41 -0700132 public int getIdleTimeout() {
133 return idleTimeout;
134 }
135
Ray Milkeyff735142014-05-22 19:06:02 -0700136 // TODO - this is intended to be refactored and removed
TeruU30c0c932014-05-15 16:47:41 -0700137 public int getHardTimeout() {
138 return hardTimeout;
139 }
140
Ray Milkeyff735142014-05-22 19:06:02 -0700141 // TODO - this is intended to be refactored and removed
TeruU30c0c932014-05-15 16:47:41 -0700142 public void setIdleTimeout(int idleTimeout) {
143 this.idleTimeout = idleTimeout;
144 }
145
Ray Milkeyff735142014-05-22 19:06:02 -0700146 // TODO - this is intended to be refactored and removed
TeruU30c0c932014-05-15 16:47:41 -0700147 public void setHardTimeout(int hardTimeout) {
148 this.hardTimeout = hardTimeout;
149 }
150
Ray Milkeyff735142014-05-22 19:06:02 -0700151 // TODO - this is intended to be refactored and removed
TeruU30c0c932014-05-15 16:47:41 -0700152 public int getFirstSwitchIdleTimeout() {
153 return firstSwitchIdleTimeout;
154 }
155
Ray Milkeyff735142014-05-22 19:06:02 -0700156 // TODO - this is intended to be refactored and removed
Jonathan Hart33e1f302014-05-30 14:37:09 -0700157 public int getFirstSwitchHardTimeout() {
Jonathan Hart4dc8d872014-05-30 14:23:25 -0700158 return firstSwitchHardTimeout;
TeruU30c0c932014-05-15 16:47:41 -0700159 }
160
Ray Milkeyff735142014-05-22 19:06:02 -0700161 // TODO - this is intended to be refactored and removed
TeruU30c0c932014-05-15 16:47:41 -0700162 public void setFirstSwitchIdleTimeout(int firstSwitchIdleTimeout) {
163 this.firstSwitchIdleTimeout = firstSwitchIdleTimeout;
164 }
165
Ray Milkeyff735142014-05-22 19:06:02 -0700166 // TODO - this is intended to be refactored and removed
Jonathan Hart33e1f302014-05-30 14:37:09 -0700167 public void setFirstSwitchHardTimeout(int firstSwitchHardTimeout) {
168 this.firstSwitchHardTimeout = firstSwitchHardTimeout;
TeruU30c0c932014-05-15 16:47:41 -0700169 }
170
Ray Milkey269ffb92014-04-03 14:43:30 -0700171 @Override
Pavlin Radoslavov7fb16412014-04-11 18:45:19 -0700172 public int hashCode() {
173 // TODO: Is this the intended behavior?
174 return (super.hashCode());
175 }
176
177 @Override
178 public boolean equals(Object obj) {
179 // TODO: Is this the intended behavior?
180 return (super.equals(obj));
181 }
182
183 @Override
Ray Milkey269ffb92014-04-03 14:43:30 -0700184 public String toString() {
Jonathan Hartc00f5c22014-06-10 15:14:40 -0700185 return String.format("id:%s, state:%s, srcDpid:%s, srcPort:%d, " +
186 "srcMac:%s, srcIP:%s, dstDpid:%s, dstPort:%d, dstMac:%s, dstIP:%s",
Ray Milkey269ffb92014-04-03 14:43:30 -0700187 getId(), getState(),
Jonathan Hartc00f5c22014-06-10 15:14:40 -0700188 new Dpid(srcSwitchDpid), srcPortNumber,
189 MACAddress.valueOf(srcMacAddress), Integer.toString(srcIpAddress),
190 new Dpid(dstSwitchDpid), dstPortNumber,
191 MACAddress.valueOf(dstMacAddress), Integer.toString(dstIpAddress));
Komal Shah399a2922014-05-28 01:57:40 -0700192 }
193
194 public int getSrcIp() {
195 return srcIpAddress;
196 }
197
198 public int getDstIp() {
199 return dstIpAddress;
Ray Milkey269ffb92014-04-03 14:43:30 -0700200 }
Toshio Koidead17d5e2014-02-11 11:36:02 -0800201}