blob: 1d5606fe9f61e12d8cf818199c6d42945f1e9599 [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 {
Komal Shah399a2922014-05-28 01:57:40 -070010 public static final long EMPTYMACADDRESS = 0;
11 public static final int EMPTYIPADDRESS = 0;
Ray Milkey269ffb92014-04-03 14:43:30 -070012 protected long srcSwitchDpid;
13 protected long srcPortNumber;
14 protected long srcMacAddress;
15 protected long dstSwitchDpid;
16 protected long dstPortNumber;
17 protected long dstMacAddress;
Komal Shah399a2922014-05-28 01:57:40 -070018 protected int srcIpAddress;
19 protected int dstIpAddress;
Ray Milkey269ffb92014-04-03 14:43:30 -070020 protected String pathIntentId = null;
TeruU30c0c932014-05-15 16:47:41 -070021 protected int idleTimeout;
22 protected int hardTimeout;
23 protected int firstSwitchIdleTimeout;
24 protected int firstSwitchHardTimetout;
Toshio Koidead17d5e2014-02-11 11:36:02 -080025
Ray Milkey269ffb92014-04-03 14:43:30 -070026 /**
Ray Milkeyb41100a2014-04-10 10:42:15 -070027 * Default constructor for Kryo deserialization.
Ray Milkey269ffb92014-04-03 14:43:30 -070028 */
29 protected ShortestPathIntent() {
30 }
Toshio Koidead17d5e2014-02-11 11:36:02 -080031
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070032 /**
33 * Constructor for ShortestPathIntent.
34 *
35 * @param id Intent ID
36 * @param srcSwitch Source Switch DPID
37 * @param srcPort Source Port
38 * @param srcMac Source Host MAC Address
39 * @param dstSwitch Destination Switch DPID
40 * @param dstPort Destination Port
41 * @param dstMac Destination Host MAC Address
42 */
Ray Milkey269ffb92014-04-03 14:43:30 -070043 public ShortestPathIntent(String id,
44 long srcSwitch, long srcPort, long srcMac,
45 long dstSwitch, long dstPort, long dstMac) {
Komal Shah399a2922014-05-28 01:57:40 -070046 //super(id);
47 this(id, srcSwitch, srcPort, srcMac, EMPTYIPADDRESS, dstSwitch, dstPort, dstMac, EMPTYIPADDRESS);
48 }
49
50 // CHECKSTYLE:OFF suppress the warning about too many parameters
51 public ShortestPathIntent(String id,
52 long srcSwitch, long srcPort, long srcMac, int srcIp,
53 long dstSwitch, long dstPort, long dstMac, int dstIp ) {
54 // CHECKSTYLE:ON
Ray Milkey269ffb92014-04-03 14:43:30 -070055 super(id);
Komal Shah399a2922014-05-28 01:57:40 -070056 this.srcSwitchDpid = srcSwitch;
57 this.srcPortNumber = srcPort;
58 this.srcMacAddress = srcMac;
59 this.dstSwitchDpid = dstSwitch;
60 this.dstPortNumber = dstPort;
61 this.dstMacAddress = dstMac;
62 this.srcIpAddress = srcIp;
63 this.dstIpAddress = dstIp;
Ray Milkey269ffb92014-04-03 14:43:30 -070064 }
Toshio Koidead17d5e2014-02-11 11:36:02 -080065
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070066 /**
67 * Gets the source Switch DPID.
68 *
69 * @return Source Switch DPID
70 */
Ray Milkey269ffb92014-04-03 14:43:30 -070071 public long getSrcSwitchDpid() {
72 return srcSwitchDpid;
73 }
Toshio Koidead17d5e2014-02-11 11:36:02 -080074
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070075 /**
76 * Gets the source Port.
77 *
78 * @return Source Port
79 */
Ray Milkey269ffb92014-04-03 14:43:30 -070080 public long getSrcPortNumber() {
81 return srcPortNumber;
82 }
Toshio Koidead17d5e2014-02-11 11:36:02 -080083
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070084 /**
85 * Gets the source Host MAC Address.
86 *
87 * @return Source Host MAC Address
88 */
Ray Milkey269ffb92014-04-03 14:43:30 -070089 public long getSrcMac() {
90 return srcMacAddress;
91 }
Toshio Koidead17d5e2014-02-11 11:36:02 -080092
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070093 /**
94 * Gets the destination Switch DPID.
95 *
96 * @return Destination Switch DPID
97 */
Ray Milkey269ffb92014-04-03 14:43:30 -070098 public long getDstSwitchDpid() {
99 return dstSwitchDpid;
100 }
Toshio Koide0e4d8d22014-02-14 10:56:10 -0800101
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -0700102 /**
103 * Gets the destination Port.
104 *
105 * @return Destination Port
106 */
Ray Milkey269ffb92014-04-03 14:43:30 -0700107 public long getDstPortNumber() {
108 return dstPortNumber;
109 }
Toshio Koide0e4d8d22014-02-14 10:56:10 -0800110
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -0700111 /**
112 * Gets the destination Host MAC Address.
113 *
114 * @return Destination Host MAC Address
115 */
Ray Milkey269ffb92014-04-03 14:43:30 -0700116 public long getDstMac() {
117 return dstMacAddress;
118 }
Toshio Koidead17d5e2014-02-11 11:36:02 -0800119
Ray Milkey269ffb92014-04-03 14:43:30 -0700120 public void setPathIntent(PathIntent pathIntent) {
121 pathIntentId = pathIntent.getId();
122 }
Toshio Koidea10c0372014-02-20 17:28:10 -0800123
Ray Milkey269ffb92014-04-03 14:43:30 -0700124 public String getPathIntentId() {
125 return pathIntentId;
126 }
Toshio Koidea10c0372014-02-20 17:28:10 -0800127
Ray Milkeyff735142014-05-22 19:06:02 -0700128 // TODO - this is intended to be refactored and removed
TeruU30c0c932014-05-15 16:47:41 -0700129 public int getIdleTimeout() {
130 return idleTimeout;
131 }
132
Ray Milkeyff735142014-05-22 19:06:02 -0700133 // TODO - this is intended to be refactored and removed
TeruU30c0c932014-05-15 16:47:41 -0700134 public int getHardTimeout() {
135 return hardTimeout;
136 }
137
Ray Milkeyff735142014-05-22 19:06:02 -0700138 // TODO - this is intended to be refactored and removed
TeruU30c0c932014-05-15 16:47:41 -0700139 public void setIdleTimeout(int idleTimeout) {
140 this.idleTimeout = idleTimeout;
141 }
142
Ray Milkeyff735142014-05-22 19:06:02 -0700143 // TODO - this is intended to be refactored and removed
TeruU30c0c932014-05-15 16:47:41 -0700144 public void setHardTimeout(int hardTimeout) {
145 this.hardTimeout = hardTimeout;
146 }
147
Ray Milkeyff735142014-05-22 19:06:02 -0700148 // TODO - this is intended to be refactored and removed
TeruU30c0c932014-05-15 16:47:41 -0700149 public int getFirstSwitchIdleTimeout() {
150 return firstSwitchIdleTimeout;
151 }
152
Ray Milkeyff735142014-05-22 19:06:02 -0700153 // TODO - this is intended to be refactored and removed
TeruU30c0c932014-05-15 16:47:41 -0700154 public int getFirstSwitchHardTimetout() {
155 return firstSwitchHardTimetout;
156 }
157
Ray Milkeyff735142014-05-22 19:06:02 -0700158 // TODO - this is intended to be refactored and removed
TeruU30c0c932014-05-15 16:47:41 -0700159 public void setFirstSwitchIdleTimeout(int firstSwitchIdleTimeout) {
160 this.firstSwitchIdleTimeout = firstSwitchIdleTimeout;
161 }
162
Ray Milkeyff735142014-05-22 19:06:02 -0700163 // TODO - this is intended to be refactored and removed
TeruU30c0c932014-05-15 16:47:41 -0700164 public void setFirstSwitchHardTimetout(int firstSwitchHardTimetout) {
165 this.firstSwitchHardTimetout = firstSwitchHardTimetout;
166 }
167
Ray Milkey269ffb92014-04-03 14:43:30 -0700168 @Override
Pavlin Radoslavov7fb16412014-04-11 18:45:19 -0700169 public int hashCode() {
170 // TODO: Is this the intended behavior?
171 return (super.hashCode());
172 }
173
174 @Override
175 public boolean equals(Object obj) {
176 // TODO: Is this the intended behavior?
177 return (super.equals(obj));
178 }
179
180 @Override
Ray Milkey269ffb92014-04-03 14:43:30 -0700181 public String toString() {
Komal Shah399a2922014-05-28 01:57:40 -0700182 return String.format("id:%s, state:%s, srcDpid:%s, srcPort:%d, srcMac:%s, srcIP:%s, dstDpid:%s, dstPort:%d, dstMac:%s, dstIP:%s",
Ray Milkey269ffb92014-04-03 14:43:30 -0700183 getId(), getState(),
Komal Shah399a2922014-05-28 01:57:40 -0700184 new Dpid(srcSwitchDpid), srcPortNumber, MACAddress.valueOf(srcMacAddress), Integer.toString(srcIpAddress),
185 new Dpid(dstSwitchDpid), dstPortNumber, MACAddress.valueOf(dstMacAddress), Integer.toString(dstIpAddress));
186 }
187
188 public int getSrcIp() {
189 return srcIpAddress;
190 }
191
192 public int getDstIp() {
193 return dstIpAddress;
Ray Milkey269ffb92014-04-03 14:43:30 -0700194 }
Toshio Koidead17d5e2014-02-11 11:36:02 -0800195}