Jonathan Hart | aa38097 | 2014-04-03 10:24:46 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.intent; |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 2 | |
| 3 | import net.floodlightcontroller.util.MACAddress; |
Jonathan Hart | 23701d1 | 2014-04-03 10:45:48 -0700 | [diff] [blame] | 4 | import net.onrc.onos.core.util.Dpid; |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 5 | |
| 6 | /** |
| 7 | * @author Toshio Koide (t-koide@onlab.us) |
| 8 | */ |
| 9 | public class ShortestPathIntent extends Intent { |
Komal Shah | 399a292 | 2014-05-28 01:57:40 -0700 | [diff] [blame] | 10 | public static final long EMPTYMACADDRESS = 0; |
| 11 | public static final int EMPTYIPADDRESS = 0; |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 12 | protected long srcSwitchDpid; |
| 13 | protected long srcPortNumber; |
| 14 | protected long srcMacAddress; |
| 15 | protected long dstSwitchDpid; |
| 16 | protected long dstPortNumber; |
| 17 | protected long dstMacAddress; |
Komal Shah | 399a292 | 2014-05-28 01:57:40 -0700 | [diff] [blame] | 18 | protected int srcIpAddress; |
| 19 | protected int dstIpAddress; |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 20 | protected String pathIntentId = null; |
TeruU | 30c0c93 | 2014-05-15 16:47:41 -0700 | [diff] [blame] | 21 | protected int idleTimeout; |
| 22 | protected int hardTimeout; |
| 23 | protected int firstSwitchIdleTimeout; |
Jonathan Hart | 4dc8d87 | 2014-05-30 14:23:25 -0700 | [diff] [blame] | 24 | protected int firstSwitchHardTimeout; |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 25 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 26 | /** |
Ray Milkey | b41100a | 2014-04-10 10:42:15 -0700 | [diff] [blame] | 27 | * Default constructor for Kryo deserialization. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 28 | */ |
| 29 | protected ShortestPathIntent() { |
| 30 | } |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 31 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 32 | /** |
| 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 Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 43 | public ShortestPathIntent(String id, |
| 44 | long srcSwitch, long srcPort, long srcMac, |
| 45 | long dstSwitch, long dstPort, long dstMac) { |
Komal Shah | 399a292 | 2014-05-28 01:57:40 -0700 | [diff] [blame] | 46 | //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 Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 55 | super(id); |
Komal Shah | 399a292 | 2014-05-28 01:57:40 -0700 | [diff] [blame] | 56 | 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 Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 64 | } |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 65 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 66 | /** |
| 67 | * Gets the source Switch DPID. |
| 68 | * |
| 69 | * @return Source Switch DPID |
| 70 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 71 | public long getSrcSwitchDpid() { |
| 72 | return srcSwitchDpid; |
| 73 | } |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 74 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 75 | /** |
| 76 | * Gets the source Port. |
| 77 | * |
| 78 | * @return Source Port |
| 79 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 80 | public long getSrcPortNumber() { |
| 81 | return srcPortNumber; |
| 82 | } |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 83 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 84 | /** |
| 85 | * Gets the source Host MAC Address. |
| 86 | * |
| 87 | * @return Source Host MAC Address |
| 88 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 89 | public long getSrcMac() { |
| 90 | return srcMacAddress; |
| 91 | } |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 92 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 93 | /** |
| 94 | * Gets the destination Switch DPID. |
| 95 | * |
| 96 | * @return Destination Switch DPID |
| 97 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 98 | public long getDstSwitchDpid() { |
| 99 | return dstSwitchDpid; |
| 100 | } |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 101 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 102 | /** |
| 103 | * Gets the destination Port. |
| 104 | * |
| 105 | * @return Destination Port |
| 106 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 107 | public long getDstPortNumber() { |
| 108 | return dstPortNumber; |
| 109 | } |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 110 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 111 | /** |
| 112 | * Gets the destination Host MAC Address. |
| 113 | * |
| 114 | * @return Destination Host MAC Address |
| 115 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 116 | public long getDstMac() { |
| 117 | return dstMacAddress; |
| 118 | } |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 119 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 120 | public void setPathIntent(PathIntent pathIntent) { |
| 121 | pathIntentId = pathIntent.getId(); |
| 122 | } |
Toshio Koide | a10c037 | 2014-02-20 17:28:10 -0800 | [diff] [blame] | 123 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 124 | public String getPathIntentId() { |
| 125 | return pathIntentId; |
| 126 | } |
Toshio Koide | a10c037 | 2014-02-20 17:28:10 -0800 | [diff] [blame] | 127 | |
Ray Milkey | ff73514 | 2014-05-22 19:06:02 -0700 | [diff] [blame] | 128 | // TODO - this is intended to be refactored and removed |
TeruU | 30c0c93 | 2014-05-15 16:47:41 -0700 | [diff] [blame] | 129 | public int getIdleTimeout() { |
| 130 | return idleTimeout; |
| 131 | } |
| 132 | |
Ray Milkey | ff73514 | 2014-05-22 19:06:02 -0700 | [diff] [blame] | 133 | // TODO - this is intended to be refactored and removed |
TeruU | 30c0c93 | 2014-05-15 16:47:41 -0700 | [diff] [blame] | 134 | public int getHardTimeout() { |
| 135 | return hardTimeout; |
| 136 | } |
| 137 | |
Ray Milkey | ff73514 | 2014-05-22 19:06:02 -0700 | [diff] [blame] | 138 | // TODO - this is intended to be refactored and removed |
TeruU | 30c0c93 | 2014-05-15 16:47:41 -0700 | [diff] [blame] | 139 | public void setIdleTimeout(int idleTimeout) { |
| 140 | this.idleTimeout = idleTimeout; |
| 141 | } |
| 142 | |
Ray Milkey | ff73514 | 2014-05-22 19:06:02 -0700 | [diff] [blame] | 143 | // TODO - this is intended to be refactored and removed |
TeruU | 30c0c93 | 2014-05-15 16:47:41 -0700 | [diff] [blame] | 144 | public void setHardTimeout(int hardTimeout) { |
| 145 | this.hardTimeout = hardTimeout; |
| 146 | } |
| 147 | |
Ray Milkey | ff73514 | 2014-05-22 19:06:02 -0700 | [diff] [blame] | 148 | // TODO - this is intended to be refactored and removed |
TeruU | 30c0c93 | 2014-05-15 16:47:41 -0700 | [diff] [blame] | 149 | public int getFirstSwitchIdleTimeout() { |
| 150 | return firstSwitchIdleTimeout; |
| 151 | } |
| 152 | |
Ray Milkey | ff73514 | 2014-05-22 19:06:02 -0700 | [diff] [blame] | 153 | // TODO - this is intended to be refactored and removed |
Jonathan Hart | 33e1f30 | 2014-05-30 14:37:09 -0700 | [diff] [blame^] | 154 | public int getFirstSwitchHardTimeout() { |
Jonathan Hart | 4dc8d87 | 2014-05-30 14:23:25 -0700 | [diff] [blame] | 155 | return firstSwitchHardTimeout; |
TeruU | 30c0c93 | 2014-05-15 16:47:41 -0700 | [diff] [blame] | 156 | } |
| 157 | |
Ray Milkey | ff73514 | 2014-05-22 19:06:02 -0700 | [diff] [blame] | 158 | // TODO - this is intended to be refactored and removed |
TeruU | 30c0c93 | 2014-05-15 16:47:41 -0700 | [diff] [blame] | 159 | public void setFirstSwitchIdleTimeout(int firstSwitchIdleTimeout) { |
| 160 | this.firstSwitchIdleTimeout = firstSwitchIdleTimeout; |
| 161 | } |
| 162 | |
Ray Milkey | ff73514 | 2014-05-22 19:06:02 -0700 | [diff] [blame] | 163 | // TODO - this is intended to be refactored and removed |
Jonathan Hart | 33e1f30 | 2014-05-30 14:37:09 -0700 | [diff] [blame^] | 164 | public void setFirstSwitchHardTimeout(int firstSwitchHardTimeout) { |
| 165 | this.firstSwitchHardTimeout = firstSwitchHardTimeout; |
TeruU | 30c0c93 | 2014-05-15 16:47:41 -0700 | [diff] [blame] | 166 | } |
| 167 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 168 | @Override |
Pavlin Radoslavov | 7fb1641 | 2014-04-11 18:45:19 -0700 | [diff] [blame] | 169 | 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 Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 181 | public String toString() { |
Komal Shah | 399a292 | 2014-05-28 01:57:40 -0700 | [diff] [blame] | 182 | return String.format("id:%s, state:%s, srcDpid:%s, srcPort:%d, srcMac:%s, srcIP:%s, dstDpid:%s, dstPort:%d, dstMac:%s, dstIP:%s", |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 183 | getId(), getState(), |
Komal Shah | 399a292 | 2014-05-28 01:57:40 -0700 | [diff] [blame] | 184 | 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 Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 194 | } |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 195 | } |