Jonathan Hart | 23701d1 | 2014-04-03 10:45:48 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.util; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 2 | |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 3 | |
Pankaj Berde | d0ae0ff | 2013-03-26 15:37:12 -0700 | [diff] [blame] | 4 | import org.codehaus.jackson.annotate.JsonIgnore; |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 5 | import org.codehaus.jackson.annotate.JsonProperty; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 6 | |
| 7 | /** |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 8 | * The class representing the Flow Entry. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 9 | * <p/> |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 10 | * NOTE: The specification is incomplete. E.g., the entry needs to |
| 11 | * support multiple in-ports and multiple out-ports. |
| 12 | */ |
| 13 | public class FlowEntry { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 14 | private FlowId flowId; // FlowID of the Flow Entry |
| 15 | private FlowEntryId flowEntryId; // The Flow Entry ID |
| 16 | private int idleTimeout; // The Flow idle timeout |
| 17 | private int hardTimeout; // The Flow hard timeout |
| 18 | private int priority; // The Flow priority |
| 19 | private FlowEntryMatch flowEntryMatch; // The Flow Entry Match |
| 20 | private FlowEntryActions flowEntryActions; // The Flow Entry Actions |
| 21 | private Dpid dpid; // The Switch DPID |
| 22 | private Port inPort; // The Switch incoming port. Used only |
| 23 | // when the entry is used to return |
| 24 | // Shortest Path computation. |
| 25 | private Port outPort; // The Switch outgoing port. Used only |
| 26 | // when the entry is used to return |
| 27 | // Shortest Path computation. |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 28 | private FlowEntryUserState flowEntryUserState; // The Flow Entry User state |
| 29 | private FlowEntrySwitchState flowEntrySwitchState; // The Flow Entry Switch state |
| 30 | // The Flow Entry Error state (if FlowEntrySwitchState is FE_SWITCH_FAILED) |
| 31 | private FlowEntryErrorState flowEntryErrorState; |
| 32 | |
| 33 | /** |
| 34 | * Default constructor. |
| 35 | */ |
| 36 | public FlowEntry() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 37 | // TODO: Test code |
| 38 | /* |
| 39 | MACAddress mac = MACAddress.valueOf("01:02:03:04:05:06"); |
| 40 | IPv4 ipv4 = new IPv4("1.2.3.4"); |
| 41 | IPv4Net ipv4net = new IPv4Net("5.6.7.0/24"); |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 42 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 43 | flowEntryMatch = new FlowEntryMatch(); |
| 44 | flowEntryMatch.enableInPort(new Port((short)10)); |
| 45 | flowEntryMatch.enableSrcMac(mac); |
| 46 | flowEntryMatch.enableDstMac(mac); |
| 47 | flowEntryMatch.enableVlanId((short)20); |
| 48 | flowEntryMatch.enableVlanPriority((byte)30); |
| 49 | flowEntryMatch.enableEthernetFrameType((short)40); |
| 50 | flowEntryMatch.enableIpToS((byte)50); |
| 51 | flowEntryMatch.enableIpProto((byte)60); |
| 52 | flowEntryMatch.enableSrcIPv4Net(ipv4net); |
| 53 | flowEntryMatch.enableDstIPv4Net(ipv4net); |
| 54 | flowEntryMatch.enableSrcTcpUdpPort((short)70); |
| 55 | flowEntryMatch.enableDstTcpUdpPort((short)80); |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 56 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 57 | FlowEntryAction action = null; |
| 58 | FlowEntryActions actions = new FlowEntryActions(); |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 59 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 60 | action = new FlowEntryAction(); |
| 61 | action.setActionOutput(new Port((short)12)); |
| 62 | actions.addAction(action); |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 63 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 64 | action = new FlowEntryAction(); |
| 65 | action.setActionOutputToController((short)13); |
| 66 | actions.addAction(action); |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 67 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 68 | action = new FlowEntryAction(); |
| 69 | action.setActionSetVlanId((short)14); |
| 70 | actions.addAction(action); |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 71 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 72 | action = new FlowEntryAction(); |
| 73 | action.setActionSetVlanPriority((byte)15); |
| 74 | actions.addAction(action); |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 75 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 76 | action = new FlowEntryAction(); |
| 77 | action.setActionStripVlan(true); |
| 78 | actions.addAction(action); |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 79 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 80 | action = new FlowEntryAction(); |
| 81 | action.setActionSetEthernetSrcAddr(mac); |
| 82 | actions.addAction(action); |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 83 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 84 | action = new FlowEntryAction(); |
| 85 | action.setActionSetEthernetDstAddr(mac); |
| 86 | actions.addAction(action); |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 87 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 88 | action = new FlowEntryAction(); |
| 89 | action.setActionSetIPv4SrcAddr(ipv4); |
| 90 | actions.addAction(action); |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 91 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 92 | action = new FlowEntryAction(); |
| 93 | action.setActionSetIPv4DstAddr(ipv4); |
| 94 | actions.addAction(action); |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 95 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 96 | action = new FlowEntryAction(); |
| 97 | action.setActionSetIpToS((byte)16); |
| 98 | actions.addAction(action); |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 99 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 100 | action = new FlowEntryAction(); |
| 101 | action.setActionSetTcpUdpSrcPort((short)17); |
| 102 | actions.addAction(action); |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 103 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 104 | action = new FlowEntryAction(); |
| 105 | action.setActionSetTcpUdpDstPort((short)18); |
| 106 | actions.addAction(action); |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 107 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 108 | action = new FlowEntryAction(); |
| 109 | action.setActionEnqueue(new Port((short)19), 20); |
| 110 | actions.addAction(action); |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 111 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 112 | setFlowEntryActions(actions); |
| 113 | */ |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 114 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 115 | priority = FlowPath.PRIORITY_DEFAULT; |
| 116 | flowEntryActions = new FlowEntryActions(); |
| 117 | flowEntryUserState = FlowEntryUserState.FE_USER_UNKNOWN; |
| 118 | flowEntrySwitchState = FlowEntrySwitchState.FE_SWITCH_UNKNOWN; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | /** |
Pavlin Radoslavov | 5f85c7b | 2013-03-28 05:33:57 -0700 | [diff] [blame] | 122 | * Get the Flow ID. |
Pavlin Radoslavov | 062c72d | 2013-10-30 12:42:15 -0700 | [diff] [blame] | 123 | * |
Pavlin Radoslavov | 5f85c7b | 2013-03-28 05:33:57 -0700 | [diff] [blame] | 124 | * @return the Flow ID. |
| 125 | */ |
| 126 | @JsonIgnore |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 127 | public FlowId flowId() { |
| 128 | return flowId; |
| 129 | } |
Pavlin Radoslavov | 5f85c7b | 2013-03-28 05:33:57 -0700 | [diff] [blame] | 130 | |
| 131 | /** |
| 132 | * Set the Flow ID. |
| 133 | * |
| 134 | * @param flowId the Flow ID to set. |
| 135 | */ |
| 136 | public void setFlowId(FlowId flowId) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 137 | this.flowId = flowId; |
Pavlin Radoslavov | 5f85c7b | 2013-03-28 05:33:57 -0700 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | /** |
Pavlin Radoslavov | 062c72d | 2013-10-30 12:42:15 -0700 | [diff] [blame] | 141 | * Test whether the Flow ID is valid. |
| 142 | * |
| 143 | * @return true if the Flow ID is valid, otherwise false. |
| 144 | */ |
Pavlin Radoslavov | da26a9a | 2013-11-22 19:31:36 -0800 | [diff] [blame] | 145 | @JsonIgnore |
Pavlin Radoslavov | 062c72d | 2013-10-30 12:42:15 -0700 | [diff] [blame] | 146 | public boolean isValidFlowId() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 147 | if (this.flowId == null) |
| 148 | return false; |
| 149 | return (this.flowId.isValid()); |
Pavlin Radoslavov | 062c72d | 2013-10-30 12:42:15 -0700 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | /** |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 153 | * Get the Flow Entry ID. |
| 154 | * |
| 155 | * @return the Flow Entry ID. |
| 156 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 157 | @JsonProperty("flowEntryId") |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 158 | public FlowEntryId flowEntryId() { |
| 159 | return flowEntryId; |
| 160 | } |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 161 | |
| 162 | /** |
| 163 | * Set the Flow Entry ID. |
| 164 | * |
| 165 | * @param flowEntryId the Flow Entry ID to set. |
| 166 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 167 | @JsonProperty("flowEntryId") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 168 | public void setFlowEntryId(FlowEntryId flowEntryId) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 169 | this.flowEntryId = flowEntryId; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | /** |
Pavlin Radoslavov | b1309e8 | 2013-10-30 12:18:28 -0700 | [diff] [blame] | 173 | * Test whether the Flow Entry ID is valid. |
| 174 | * |
| 175 | * @return true if the Flow Entry ID is valid, otherwise false. |
| 176 | */ |
Pavlin Radoslavov | da26a9a | 2013-11-22 19:31:36 -0800 | [diff] [blame] | 177 | @JsonIgnore |
Pavlin Radoslavov | b1309e8 | 2013-10-30 12:18:28 -0700 | [diff] [blame] | 178 | public boolean isValidFlowEntryId() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 179 | if (this.flowEntryId == null) |
| 180 | return false; |
| 181 | return (this.flowEntryId.isValid()); |
Pavlin Radoslavov | b1309e8 | 2013-10-30 12:18:28 -0700 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | /** |
Pavlin Radoslavov | 5139c0b | 2013-12-09 18:04:53 -0800 | [diff] [blame] | 185 | * Get the flow idle timeout in seconds. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 186 | * <p/> |
Pavlin Radoslavov | 5139c0b | 2013-12-09 18:04:53 -0800 | [diff] [blame] | 187 | * It should be an unsigned integer in the interval [0, 65535]. |
| 188 | * If zero, the timeout is not set. |
| 189 | * |
| 190 | * @return the flow idle timeout. |
| 191 | */ |
| 192 | @JsonProperty("idleTimeout") |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 193 | public int idleTimeout() { |
| 194 | return idleTimeout; |
| 195 | } |
Pavlin Radoslavov | 5139c0b | 2013-12-09 18:04:53 -0800 | [diff] [blame] | 196 | |
| 197 | /** |
| 198 | * Set the flow idle timeout in seconds. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 199 | * <p/> |
Pavlin Radoslavov | 5139c0b | 2013-12-09 18:04:53 -0800 | [diff] [blame] | 200 | * It should be an unsigned integer in the interval [0, 65535]. |
| 201 | * If zero, the timeout is not set. |
| 202 | * |
| 203 | * @param idleTimeout the flow idle timeout to set. |
| 204 | */ |
| 205 | @JsonProperty("idleTimeout") |
| 206 | public void setIdleTimeout(int idleTimeout) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 207 | this.idleTimeout = 0xffff & idleTimeout; |
Pavlin Radoslavov | 5139c0b | 2013-12-09 18:04:53 -0800 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | /** |
| 211 | * Get the flow hard timeout in seconds. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 212 | * <p/> |
Pavlin Radoslavov | 5139c0b | 2013-12-09 18:04:53 -0800 | [diff] [blame] | 213 | * It should be an unsigned integer in the interval [0, 65535]. |
| 214 | * If zero, the timeout is not set. |
| 215 | * |
| 216 | * @return the flow hard timeout. |
| 217 | */ |
| 218 | @JsonProperty("hardTimeout") |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 219 | public int hardTimeout() { |
| 220 | return hardTimeout; |
| 221 | } |
Pavlin Radoslavov | 5139c0b | 2013-12-09 18:04:53 -0800 | [diff] [blame] | 222 | |
| 223 | /** |
| 224 | * Set the flow hard timeout in seconds. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 225 | * <p/> |
Pavlin Radoslavov | 5139c0b | 2013-12-09 18:04:53 -0800 | [diff] [blame] | 226 | * It should be an unsigned integer in the interval [0, 65535]. |
| 227 | * If zero, the timeout is not set. |
| 228 | * |
| 229 | * @param hardTimeout the flow hard timeout to set. |
| 230 | */ |
| 231 | @JsonProperty("hardTimeout") |
| 232 | public void setHardTimeout(int hardTimeout) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 233 | this.hardTimeout = 0xffff & hardTimeout; |
Pavlin Radoslavov | 5139c0b | 2013-12-09 18:04:53 -0800 | [diff] [blame] | 234 | } |
| 235 | |
| 236 | /** |
Pavlin Radoslavov | afbf103 | 2014-02-04 10:37:52 -0800 | [diff] [blame] | 237 | * Get the flow priority. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 238 | * <p/> |
Pavlin Radoslavov | afbf103 | 2014-02-04 10:37:52 -0800 | [diff] [blame] | 239 | * It should be an unsigned integer in the interval [0, 65535]. |
| 240 | * |
| 241 | * @return the flow priority. |
| 242 | */ |
| 243 | @JsonProperty("priority") |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 244 | public int priority() { |
| 245 | return priority; |
| 246 | } |
Pavlin Radoslavov | afbf103 | 2014-02-04 10:37:52 -0800 | [diff] [blame] | 247 | |
| 248 | /** |
| 249 | * Set the flow priority. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 250 | * <p/> |
Pavlin Radoslavov | afbf103 | 2014-02-04 10:37:52 -0800 | [diff] [blame] | 251 | * It should be an unsigned integer in the interval [0, 65535]. |
| 252 | * |
| 253 | * @param priority the flow priority to set. |
| 254 | */ |
| 255 | @JsonProperty("priority") |
| 256 | public void setPriority(int priority) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 257 | this.priority = 0xffff & priority; |
Pavlin Radoslavov | afbf103 | 2014-02-04 10:37:52 -0800 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | /** |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 261 | * Get the Flow Entry Match. |
| 262 | * |
| 263 | * @return the Flow Entry Match. |
| 264 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 265 | @JsonProperty("flowEntryMatch") |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 266 | public FlowEntryMatch flowEntryMatch() { |
| 267 | return flowEntryMatch; |
| 268 | } |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 269 | |
| 270 | /** |
| 271 | * Set the Flow Entry Match. |
| 272 | * |
| 273 | * @param flowEntryMatch the Flow Entry Match to set. |
| 274 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 275 | @JsonProperty("flowEntryMatch") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 276 | public void setFlowEntryMatch(FlowEntryMatch flowEntryMatch) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 277 | this.flowEntryMatch = flowEntryMatch; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | /** |
| 281 | * Get the Flow Entry Actions. |
| 282 | * |
| 283 | * @return the Flow Entry Actions. |
| 284 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 285 | @JsonProperty("flowEntryActions") |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 286 | public FlowEntryActions flowEntryActions() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 287 | return flowEntryActions; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 288 | } |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 289 | |
| 290 | /** |
| 291 | * Set the Flow Entry Actions. |
| 292 | * |
| 293 | * @param flowEntryActions the Flow Entry Actions to set. |
| 294 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 295 | @JsonProperty("flowEntryActions") |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 296 | public void setFlowEntryActions(FlowEntryActions flowEntryActions) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 297 | this.flowEntryActions = flowEntryActions; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | /** |
| 301 | * Get the Switch DPID. |
| 302 | * |
| 303 | * @return the Switch DPID. |
| 304 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 305 | @JsonProperty("dpid") |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 306 | public Dpid dpid() { |
| 307 | return dpid; |
| 308 | } |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 309 | |
| 310 | /** |
| 311 | * Set the Switch DPID. |
| 312 | * |
| 313 | * @param dpid the Switch DPID to set. |
| 314 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 315 | @JsonProperty("dpid") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 316 | public void setDpid(Dpid dpid) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 317 | this.dpid = dpid; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | /** |
| 321 | * Get the Switch incoming port. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 322 | * <p/> |
Pavlin Radoslavov | 67b3ef3 | 2013-04-03 02:44:48 -0700 | [diff] [blame] | 323 | * Used only when the entry is used to return Shortest Path computation. |
| 324 | * |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 325 | * @return the Switch incoming port. |
| 326 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 327 | @JsonProperty("inPort") |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 328 | public Port inPort() { |
| 329 | return inPort; |
| 330 | } |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 331 | |
| 332 | /** |
| 333 | * Set the Switch incoming port. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 334 | * <p/> |
Pavlin Radoslavov | 67b3ef3 | 2013-04-03 02:44:48 -0700 | [diff] [blame] | 335 | * Used only when the entry is used to return Shortest Path computation. |
| 336 | * |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 337 | * @param inPort the Switch incoming port to set. |
| 338 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 339 | @JsonProperty("inPort") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 340 | public void setInPort(Port inPort) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 341 | this.inPort = inPort; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 342 | } |
| 343 | |
| 344 | /** |
| 345 | * Get the Switch outgoing port. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 346 | * <p/> |
Pavlin Radoslavov | 67b3ef3 | 2013-04-03 02:44:48 -0700 | [diff] [blame] | 347 | * Used only when the entry is used to return Shortest Path computation. |
| 348 | * |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 349 | * @return the Switch outgoing port. |
| 350 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 351 | @JsonProperty("outPort") |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 352 | public Port outPort() { |
| 353 | return outPort; |
| 354 | } |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 355 | |
| 356 | /** |
| 357 | * Set the Switch outgoing port. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 358 | * <p/> |
Pavlin Radoslavov | 67b3ef3 | 2013-04-03 02:44:48 -0700 | [diff] [blame] | 359 | * Used only when the entry is used to return Shortest Path computation. |
| 360 | * |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 361 | * @param outPort the Switch outgoing port to set. |
| 362 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 363 | @JsonProperty("outPort") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 364 | public void setOutPort(Port outPort) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 365 | this.outPort = outPort; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 366 | } |
| 367 | |
| 368 | /** |
| 369 | * Get the Flow Entry User state. |
| 370 | * |
| 371 | * @return the Flow Entry User state. |
| 372 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 373 | @JsonProperty("flowEntryUserState") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 374 | public FlowEntryUserState flowEntryUserState() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 375 | return flowEntryUserState; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 376 | } |
| 377 | |
| 378 | /** |
| 379 | * Set the Flow Entry User state. |
| 380 | * |
| 381 | * @param flowEntryUserState the Flow Entry User state to set. |
| 382 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 383 | @JsonProperty("flowEntryUserState") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 384 | public void setFlowEntryUserState(FlowEntryUserState flowEntryUserState) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 385 | this.flowEntryUserState = flowEntryUserState; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 386 | } |
| 387 | |
| 388 | /** |
| 389 | * Get the Flow Entry Switch state. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 390 | * <p/> |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 391 | * The Flow Entry Error state is used if FlowEntrySwitchState is |
| 392 | * FE_SWITCH_FAILED. |
| 393 | * |
| 394 | * @return the Flow Entry Switch state. |
| 395 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 396 | @JsonProperty("flowEntrySwitchState") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 397 | public FlowEntrySwitchState flowEntrySwitchState() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 398 | return flowEntrySwitchState; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 399 | } |
| 400 | |
| 401 | /** |
| 402 | * Set the Flow Entry Switch state. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 403 | * <p/> |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 404 | * The Flow Entry Error state is used if FlowEntrySwitchState is |
| 405 | * FE_SWITCH_FAILED. |
| 406 | * |
| 407 | * @param flowEntrySwitchState the Flow Entry Switch state to set. |
| 408 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 409 | @JsonProperty("flowEntrySwitchState") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 410 | public void setFlowEntrySwitchState(FlowEntrySwitchState flowEntrySwitchState) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 411 | this.flowEntrySwitchState = flowEntrySwitchState; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 412 | } |
| 413 | |
| 414 | /** |
| 415 | * Get the Flow Entry Error state. |
| 416 | * |
| 417 | * @return the Flow Entry Error state. |
| 418 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 419 | @JsonProperty("flowEntryErrorState") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 420 | public FlowEntryErrorState flowEntryErrorState() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 421 | return flowEntryErrorState; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 422 | } |
| 423 | |
| 424 | /** |
| 425 | * Set the Flow Entry Error state. |
| 426 | * |
| 427 | * @param flowEntryErrorState the Flow Entry Error state to set. |
| 428 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 429 | @JsonProperty("flowEntryErrorState") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 430 | public void setFlowEntryErrorState(FlowEntryErrorState flowEntryErrorState) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 431 | this.flowEntryErrorState = flowEntryErrorState; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 432 | } |
| 433 | |
| 434 | /** |
| 435 | * Convert the flow entry to a string. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 436 | * <p/> |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 437 | * The string has the following form: |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 438 | * [flowEntryId=XXX idleTimeout=XXX hardTimeout=XXX priority=XXX |
| 439 | * flowEntryMatch=XXX flowEntryActions=XXX dpid=XXX |
| 440 | * inPort=XXX outPort=XXX flowEntryUserState=XXX flowEntrySwitchState=XXX |
| 441 | * flowEntryErrorState=XXX] |
| 442 | * |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 443 | * @return the flow entry as a string. |
| 444 | */ |
| 445 | @Override |
| 446 | public String toString() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 447 | StringBuilder ret = new StringBuilder(); |
| 448 | if (flowEntryId != null) { |
| 449 | ret.append("[flowEntryId=" + this.flowEntryId.toString()); |
| 450 | } else { |
| 451 | ret.append("["); |
| 452 | } |
| 453 | if (flowId != null) { |
| 454 | ret.append(" flowId=" + this.flowId.toString()); |
| 455 | } |
| 456 | ret.append(" idleTimeout=" + this.idleTimeout); |
| 457 | ret.append(" hardTimeout=" + this.hardTimeout); |
| 458 | ret.append(" priority=" + this.priority); |
| 459 | if (flowEntryMatch != null) { |
| 460 | ret.append(" flowEntryMatch=" + this.flowEntryMatch.toString()); |
| 461 | } |
| 462 | ret.append(" flowEntryActions=" + this.flowEntryActions.toString()); |
| 463 | if (dpid != null) { |
| 464 | ret.append(" dpid=" + this.dpid.toString()); |
| 465 | } |
| 466 | if (inPort != null) { |
| 467 | ret.append(" inPort=" + this.inPort.toString()); |
| 468 | } |
| 469 | if (outPort != null) { |
| 470 | ret.append(" outPort=" + this.outPort.toString()); |
| 471 | } |
| 472 | ret.append(" flowEntryUserState=" + this.flowEntryUserState); |
| 473 | ret.append(" flowEntrySwitchState=" + this.flowEntrySwitchState); |
| 474 | if (flowEntryErrorState != null) { |
| 475 | ret.append(" flowEntryErrorState=" + this.flowEntryErrorState.toString()); |
| 476 | } |
| 477 | ret.append("]"); |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 478 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame^] | 479 | return ret.toString(); |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 480 | } |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 481 | } |