Jonathan Hart | 23701d1 | 2014-04-03 10:45:48 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.util; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 2 | |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 3 | import net.floodlightcontroller.util.MACAddress; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 4 | |
| 5 | import org.codehaus.jackson.annotate.JsonProperty; |
| 6 | |
| 7 | /** |
| 8 | * The class representing a single Flow Entry action. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 9 | * <p/> |
Pavlin Radoslavov | d5b21db | 2013-07-29 17:09:53 -0700 | [diff] [blame] | 10 | * A Flow Entry action that needs to be applied to each packet. |
| 11 | * Note that it contains only a single action. Multiple actions are |
| 12 | * listed in a list inside @ref FlowEntryActions. |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 13 | */ |
| 14 | public class FlowEntryAction { |
| 15 | /** |
| 16 | * Special action values. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 17 | * <p/> |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 18 | * Those values are taken as-is from the OpenFlow-v1.0.0 specification |
| 19 | * (pp 21-22). |
| 20 | */ |
| 21 | public enum ActionValues { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 22 | ACTION_OUTPUT((short) 0x0), // Output to switch port |
| 23 | ACTION_SET_VLAN_VID((short) 0x1), // Set the 802.1q VLAN id |
| 24 | ACTION_SET_VLAN_PCP((short) 0x2), // Set the 802.1q priority |
| 25 | ACTION_STRIP_VLAN((short) 0x3), // Strip the 802.1q header |
| 26 | ACTION_SET_DL_SRC((short) 0x4), // Ethernet source address |
| 27 | ACTION_SET_DL_DST((short) 0x5), // Ethernet destination address |
| 28 | ACTION_SET_NW_SRC((short) 0x6), // IP source address |
| 29 | ACTION_SET_NW_DST((short) 0x7), // IP destination address |
| 30 | ACTION_SET_NW_TOS((short) 0x8), // IP ToS (DSCP field, 6 bits) |
| 31 | ACTION_SET_TP_SRC((short) 0x9), // TCP/UDP source port |
| 32 | ACTION_SET_TP_DST((short) 0xa), // TCP/UDP destination port |
| 33 | ACTION_ENQUEUE((short) 0xb), // Output to queue on port |
| 34 | ACTION_VENDOR((short) 0xffff); // Vendor-specific |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 35 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 36 | private final short value; // The value |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 37 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 38 | /** |
| 39 | * Constructor for a given value. |
| 40 | * |
| 41 | * @param value the value to use for the initialization. |
| 42 | */ |
| 43 | private ActionValues(short value) { |
| 44 | this.value = value; |
| 45 | } |
Pavlin Radoslavov | 020e96c | 2013-12-11 12:48:04 -0800 | [diff] [blame] | 46 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 47 | /** |
| 48 | * Get the value. |
| 49 | * |
| 50 | * @return the value. |
| 51 | */ |
| 52 | public short getValue() { |
| 53 | return value; |
| 54 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Action structure for ACTION_OUTPUT: Output to switch port. |
| 59 | */ |
Yuta HIGUCHI | 382827f | 2013-10-14 16:06:43 -0700 | [diff] [blame] | 60 | public static class ActionOutput { |
Yuta HIGUCHI | fb56450 | 2014-06-16 21:29:00 -0700 | [diff] [blame] | 61 | private PortNumber port; // Output port |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 62 | private short maxLen; // Max. length (in bytes) to send to controller |
| 63 | // if the port is set to PORT_CONTROLLER |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 64 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 65 | /** |
| 66 | * Default constructor. |
| 67 | */ |
| 68 | public ActionOutput() { |
| 69 | this.port = null; |
| 70 | this.maxLen = 0; |
| 71 | } |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 72 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 73 | /** |
| 74 | * Copy constructor. |
| 75 | * |
| 76 | * @param other the object to copy from. |
| 77 | */ |
| 78 | public ActionOutput(ActionOutput other) { |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 79 | if (other.port != null) { |
Yuta HIGUCHI | fb56450 | 2014-06-16 21:29:00 -0700 | [diff] [blame] | 80 | this.port = new PortNumber(other.port); |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 81 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 82 | this.maxLen = other.maxLen; |
| 83 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 84 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 85 | /** |
| 86 | * Constructor from a string. |
| 87 | * <p/> |
| 88 | * The string has the following form: |
| 89 | * [port=XXX maxLen=XXX] |
| 90 | * |
| 91 | * @param actionStr the action as a string. |
| 92 | */ |
| 93 | public ActionOutput(String actionStr) { |
| 94 | this.fromString(actionStr); |
| 95 | } |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 96 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 97 | /** |
| 98 | * Constructor for a given output port and maximum length. |
| 99 | * |
| 100 | * @param port the output port to set. |
| 101 | * @param maxLen the maximum length (in bytes) to send to controller |
| 102 | * if the port is set to PORT_CONTROLLER. |
| 103 | */ |
Yuta HIGUCHI | fb56450 | 2014-06-16 21:29:00 -0700 | [diff] [blame] | 104 | public ActionOutput(PortNumber port, short maxLen) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 105 | this.port = port; |
| 106 | this.maxLen = maxLen; |
| 107 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 108 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 109 | /** |
| 110 | * Constructor for a given output port. |
| 111 | * |
| 112 | * @param port the output port to set. |
| 113 | */ |
Yuta HIGUCHI | fb56450 | 2014-06-16 21:29:00 -0700 | [diff] [blame] | 114 | public ActionOutput(PortNumber port) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 115 | this.port = port; |
| 116 | this.maxLen = 0; |
| 117 | } |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 118 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 119 | /** |
| 120 | * Get the output port. |
| 121 | * |
| 122 | * @return the output port. |
| 123 | */ |
| 124 | @JsonProperty("port") |
Yuta HIGUCHI | fb56450 | 2014-06-16 21:29:00 -0700 | [diff] [blame] | 125 | public PortNumber port() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 126 | return this.port; |
| 127 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 128 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 129 | /** |
| 130 | * Get the maximum length (in bytes) to send to controller if the |
| 131 | * port is set to PORT_CONTROLLER. |
| 132 | * |
| 133 | * @return the maximum length (in bytes) to send to controller if the |
| 134 | * port is set to PORT_CONTROLLER. |
| 135 | */ |
| 136 | @JsonProperty("maxLen") |
| 137 | public short maxLen() { |
| 138 | return this.maxLen; |
| 139 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 140 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 141 | /** |
| 142 | * Convert the action to a string. |
| 143 | * <p/> |
| 144 | * The string has the following form: |
| 145 | * [port=XXX maxLen=XXX] |
| 146 | * |
| 147 | * @return the action as a string. |
| 148 | */ |
| 149 | @Override |
| 150 | public String toString() { |
| 151 | String ret = "["; |
| 152 | ret += "port=" + port.toString(); |
| 153 | ret += " maxLen=" + maxLen; |
| 154 | ret += "]"; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 155 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 156 | return ret; |
| 157 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 158 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 159 | /** |
| 160 | * Convert a string to an action. |
| 161 | * <p/> |
| 162 | * The string has the following form: |
| 163 | * [port=XXX maxLen=XXX] |
| 164 | * |
| 165 | * @param actionStr the action as a string. |
| 166 | */ |
| 167 | public void fromString(String actionStr) { |
| 168 | String[] parts = actionStr.split(" "); |
| 169 | String decode = null; |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 170 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 171 | // Decode the "port=XXX" part |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 172 | if (parts.length > 0) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 173 | decode = parts[0]; |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 174 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 175 | if (decode != null) { |
| 176 | String[] tokens = decode.split("port="); |
| 177 | if (tokens.length > 1 && tokens[1] != null) { |
| 178 | try { |
| 179 | Short valueShort = Short.valueOf(tokens[1]); |
Yuta HIGUCHI | fb56450 | 2014-06-16 21:29:00 -0700 | [diff] [blame] | 180 | port = new PortNumber(valueShort); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 181 | } catch (NumberFormatException e) { |
| 182 | throw new IllegalArgumentException("Invalid action string"); |
| 183 | } |
| 184 | } |
| 185 | } else { |
| 186 | throw new IllegalArgumentException("Invalid action string"); |
| 187 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 188 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 189 | // Decode the "maxLen=XXX" part |
| 190 | decode = null; |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 191 | if (parts.length > 1) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 192 | decode = parts[1]; |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 193 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 194 | if (decode != null) { |
| 195 | decode = decode.replace("]", ""); |
| 196 | String[] tokens = decode.split("maxLen="); |
| 197 | if (tokens.length > 1 && tokens[1] != null) { |
| 198 | try { |
| 199 | maxLen = Short.valueOf(tokens[1]); |
| 200 | } catch (NumberFormatException e) { |
| 201 | throw new IllegalArgumentException("Invalid action string"); |
| 202 | } |
| 203 | } |
| 204 | } else { |
| 205 | throw new IllegalArgumentException("Invalid action string"); |
| 206 | } |
| 207 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | /** |
Ray Milkey | b41100a | 2014-04-10 10:42:15 -0700 | [diff] [blame] | 211 | * Action structure for ACTION_SET_VLAN_VID: Set the 802.1q VLAN id. |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 212 | */ |
Yuta HIGUCHI | 382827f | 2013-10-14 16:06:43 -0700 | [diff] [blame] | 213 | public static class ActionSetVlanId { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 214 | private short vlanId; // The VLAN ID to set |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 215 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 216 | /** |
| 217 | * Default constructor. |
| 218 | */ |
| 219 | public ActionSetVlanId() { |
| 220 | this.vlanId = 0; |
| 221 | } |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 222 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 223 | /** |
| 224 | * Copy constructor. |
| 225 | * |
| 226 | * @param other the object to copy from. |
| 227 | */ |
| 228 | public ActionSetVlanId(ActionSetVlanId other) { |
| 229 | this.vlanId = other.vlanId; |
| 230 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 231 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 232 | /** |
| 233 | * Constructor from a string. |
| 234 | * <p/> |
| 235 | * The string has the following form: |
| 236 | * [vlanId=XXX] |
| 237 | * |
| 238 | * @param actionStr the action as a string. |
| 239 | */ |
| 240 | public ActionSetVlanId(String actionStr) { |
| 241 | this.fromString(actionStr); |
| 242 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 243 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 244 | /** |
| 245 | * Constructor for a given VLAN ID. |
| 246 | * |
| 247 | * @param vlanId the VLAN ID to set. |
| 248 | */ |
| 249 | public ActionSetVlanId(short vlanId) { |
| 250 | this.vlanId = vlanId; |
| 251 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 252 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 253 | /** |
| 254 | * Get the VLAN ID. |
| 255 | * |
| 256 | * @return the VLAN ID. |
| 257 | */ |
| 258 | @JsonProperty("vlanId") |
| 259 | public short vlanId() { |
| 260 | return this.vlanId; |
| 261 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 262 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 263 | /** |
| 264 | * Convert the action to a string. |
| 265 | * <p/> |
| 266 | * The string has the following form: |
| 267 | * [vlanId=XXX] |
| 268 | * |
| 269 | * @return the action as a string. |
| 270 | */ |
| 271 | @Override |
| 272 | public String toString() { |
| 273 | String ret = "["; |
| 274 | ret += "vlanId=" + this.vlanId; |
| 275 | ret += "]"; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 276 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 277 | return ret; |
| 278 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 279 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 280 | /** |
| 281 | * Convert a string to an action. |
| 282 | * <p/> |
| 283 | * The string has the following form: |
| 284 | * [vlanId=XXX] |
| 285 | * |
| 286 | * @param actionStr the action as a string. |
| 287 | */ |
| 288 | public void fromString(String actionStr) { |
| 289 | String[] parts = actionStr.split("vlanId="); |
| 290 | String decode = null; |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 291 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 292 | // Decode the value |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 293 | if (parts.length > 1) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 294 | decode = parts[1]; |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 295 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 296 | if (decode != null) { |
| 297 | decode = decode.replace("]", ""); |
| 298 | try { |
| 299 | vlanId = Short.valueOf(decode); |
| 300 | } catch (NumberFormatException e) { |
| 301 | throw new IllegalArgumentException("Invalid action string"); |
| 302 | } |
| 303 | } else { |
| 304 | throw new IllegalArgumentException("Invalid action string"); |
| 305 | } |
| 306 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 307 | } |
| 308 | |
| 309 | /** |
Ray Milkey | b41100a | 2014-04-10 10:42:15 -0700 | [diff] [blame] | 310 | * Action structure for ACTION_SET_VLAN_PCP: Set the 802.1q priority. |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 311 | */ |
Yuta HIGUCHI | 382827f | 2013-10-14 16:06:43 -0700 | [diff] [blame] | 312 | public static class ActionSetVlanPriority { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 313 | private byte vlanPriority; // The VLAN priority to set |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 314 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 315 | /** |
| 316 | * Default constructor. |
| 317 | */ |
| 318 | public ActionSetVlanPriority() { |
| 319 | this.vlanPriority = 0; |
| 320 | } |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 321 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 322 | /** |
| 323 | * Copy constructor. |
| 324 | * |
| 325 | * @param other the object to copy from. |
| 326 | */ |
| 327 | public ActionSetVlanPriority(ActionSetVlanPriority other) { |
| 328 | this.vlanPriority = other.vlanPriority; |
| 329 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 330 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 331 | /** |
| 332 | * Constructor from a string. |
| 333 | * <p/> |
| 334 | * The string has the following form: |
| 335 | * [vlanPriority=XXX] |
| 336 | * |
| 337 | * @param actionStr the action as a string. |
| 338 | */ |
| 339 | public ActionSetVlanPriority(String actionStr) { |
| 340 | this.fromString(actionStr); |
| 341 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 342 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 343 | /** |
| 344 | * Constructor for a given VLAN priority. |
| 345 | * |
| 346 | * @param vlanPriority the VLAN priority to set. |
| 347 | */ |
| 348 | public ActionSetVlanPriority(byte vlanPriority) { |
| 349 | this.vlanPriority = vlanPriority; |
| 350 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 351 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 352 | /** |
| 353 | * Get the VLAN priority. |
| 354 | * |
| 355 | * @return the VLAN priority. |
| 356 | */ |
| 357 | @JsonProperty("vlanPriority") |
| 358 | public byte vlanPriority() { |
| 359 | return this.vlanPriority; |
| 360 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 361 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 362 | /** |
| 363 | * Convert the action to a string. |
| 364 | * <p/> |
| 365 | * The string has the following form: |
| 366 | * [vlanPriority=XXX] |
| 367 | * |
| 368 | * @return the action as a string. |
| 369 | */ |
| 370 | @Override |
| 371 | public String toString() { |
| 372 | String ret = "["; |
| 373 | ret += "vlanPriority=" + this.vlanPriority; |
| 374 | ret += "]"; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 375 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 376 | return ret; |
| 377 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 378 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 379 | /** |
| 380 | * Convert a string to an action. |
| 381 | * <p/> |
| 382 | * The string has the following form: |
| 383 | * [vlanPriority=XXX] |
| 384 | * |
| 385 | * @param actionStr the action as a string. |
| 386 | */ |
| 387 | public void fromString(String actionStr) { |
| 388 | String[] parts = actionStr.split("vlanPriority="); |
| 389 | String decode = null; |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 390 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 391 | // Decode the value |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 392 | if (parts.length > 1) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 393 | decode = parts[1]; |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 394 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 395 | if (decode != null) { |
| 396 | decode = decode.replace("]", ""); |
| 397 | try { |
| 398 | vlanPriority = Byte.valueOf(decode); |
| 399 | } catch (NumberFormatException e) { |
| 400 | throw new IllegalArgumentException("Invalid action string"); |
| 401 | } |
| 402 | } else { |
| 403 | throw new IllegalArgumentException("Invalid action string"); |
| 404 | } |
| 405 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 406 | } |
| 407 | |
| 408 | /** |
Ray Milkey | b41100a | 2014-04-10 10:42:15 -0700 | [diff] [blame] | 409 | * Action structure for ACTION_STRIP_VLAN: Strip the 802.1q header. |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 410 | */ |
Yuta HIGUCHI | 382827f | 2013-10-14 16:06:43 -0700 | [diff] [blame] | 411 | public static class ActionStripVlan { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 412 | private boolean stripVlan; // If true, strip the VLAN header |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 413 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 414 | /** |
| 415 | * Default constructor. |
| 416 | */ |
| 417 | public ActionStripVlan() { |
| 418 | this.stripVlan = false; |
| 419 | } |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 420 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 421 | /** |
| 422 | * Copy constructor. |
| 423 | * |
| 424 | * @param other the object to copy from. |
| 425 | */ |
| 426 | public ActionStripVlan(ActionStripVlan other) { |
| 427 | this.stripVlan = other.stripVlan; |
| 428 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 429 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 430 | /** |
| 431 | * Constructor from a string. |
| 432 | * <p/> |
| 433 | * The string has the following form: |
| 434 | * [stripVlan=XXX] |
| 435 | * |
| 436 | * @param actionStr the action as a string. |
| 437 | */ |
| 438 | public ActionStripVlan(String actionStr) { |
| 439 | this.fromString(actionStr); |
| 440 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 441 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 442 | /** |
| 443 | * Constructor for a given boolean flag. |
| 444 | * |
| 445 | * @param stripVlan if true, strip the VLAN header. |
| 446 | */ |
| 447 | public ActionStripVlan(boolean stripVlan) { |
| 448 | this.stripVlan = stripVlan; |
| 449 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 450 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 451 | /** |
| 452 | * Get the boolean flag whether the VLAN header should be stripped. |
| 453 | * |
| 454 | * @return the boolean flag whether the VLAN header should be stripped. |
| 455 | */ |
| 456 | @JsonProperty("stripVlan") |
| 457 | public boolean stripVlan() { |
| 458 | return this.stripVlan; |
| 459 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 460 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 461 | /** |
| 462 | * Convert the action to a string. |
| 463 | * <p/> |
| 464 | * The string has the following form: |
| 465 | * [stripVlan=XXX] |
| 466 | * |
| 467 | * @return the action as a string. |
| 468 | */ |
| 469 | @Override |
| 470 | public String toString() { |
| 471 | String ret = "["; |
| 472 | ret += "stripVlan=" + this.stripVlan; |
| 473 | ret += "]"; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 474 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 475 | return ret; |
| 476 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 477 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 478 | /** |
| 479 | * Convert a string to an action. |
| 480 | * <p/> |
| 481 | * The string has the following form: |
| 482 | * [stripVlan=XXX] |
| 483 | * |
| 484 | * @param actionStr the action as a string. |
| 485 | */ |
| 486 | public void fromString(String actionStr) { |
| 487 | String[] parts = actionStr.split("stripVlan="); |
| 488 | String decode = null; |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 489 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 490 | // Decode the value |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 491 | if (parts.length > 1) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 492 | decode = parts[1]; |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 493 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 494 | if (decode != null) { |
| 495 | decode = decode.replace("]", ""); |
| 496 | stripVlan = Boolean.valueOf(decode); |
| 497 | } else { |
| 498 | throw new IllegalArgumentException("Invalid action string"); |
| 499 | } |
| 500 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 501 | } |
| 502 | |
| 503 | /** |
| 504 | * Action structure for ACTION_SET_DL_SRC and ACTION_SET_DL_DST: |
| 505 | * Set the Ethernet source/destination address. |
| 506 | */ |
Yuta HIGUCHI | 382827f | 2013-10-14 16:06:43 -0700 | [diff] [blame] | 507 | public static class ActionSetEthernetAddr { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 508 | private MACAddress addr; // The MAC address to set |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 509 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 510 | /** |
| 511 | * Default constructor. |
| 512 | */ |
| 513 | public ActionSetEthernetAddr() { |
| 514 | this.addr = null; |
| 515 | } |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 516 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 517 | /** |
| 518 | * Copy constructor. |
| 519 | * |
| 520 | * @param other the object to copy from. |
| 521 | */ |
| 522 | public ActionSetEthernetAddr(ActionSetEthernetAddr other) { |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 523 | if (other.addr != null) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 524 | this.addr = MACAddress.valueOf(other.addr.toLong()); |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 525 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 526 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 527 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 528 | /** |
| 529 | * Constructor from a string. |
| 530 | * <p/> |
| 531 | * The string has the following form: |
| 532 | * [addr=XXX] |
| 533 | * |
| 534 | * @param actionStr the action as a string. |
| 535 | */ |
| 536 | public ActionSetEthernetAddr(String actionStr) { |
| 537 | this.fromString(actionStr); |
| 538 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 539 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 540 | /** |
| 541 | * Constructor for a given MAC address. |
| 542 | * |
| 543 | * @param addr the MAC address to set. |
| 544 | */ |
| 545 | public ActionSetEthernetAddr(MACAddress addr) { |
| 546 | this.addr = addr; |
| 547 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 548 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 549 | /** |
| 550 | * Get the MAC address. |
| 551 | * |
| 552 | * @return the MAC address. |
| 553 | */ |
| 554 | @JsonProperty("addr") |
| 555 | public MACAddress addr() { |
| 556 | return this.addr; |
| 557 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 558 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 559 | /** |
| 560 | * Convert the action to a string. |
| 561 | * <p/> |
| 562 | * The string has the following form: |
| 563 | * [addr=XXX] |
| 564 | * |
| 565 | * @return the action as a string. |
| 566 | */ |
| 567 | @Override |
| 568 | public String toString() { |
| 569 | String ret = "["; |
| 570 | ret += "addr=" + addr.toString(); |
| 571 | ret += "]"; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 572 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 573 | return ret; |
| 574 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 575 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 576 | /** |
| 577 | * Convert a string to an action. |
| 578 | * <p/> |
| 579 | * The string has the following form: |
| 580 | * [addr=XXX] |
| 581 | * |
| 582 | * @param actionStr the action as a string. |
| 583 | */ |
| 584 | public void fromString(String actionStr) { |
| 585 | String[] parts = actionStr.split("addr="); |
| 586 | String decode = null; |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 587 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 588 | // Decode the value |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 589 | if (parts.length > 1) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 590 | decode = parts[1]; |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 591 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 592 | if (decode != null) { |
| 593 | decode = decode.replace("]", ""); |
| 594 | try { |
| 595 | addr = MACAddress.valueOf(decode); |
| 596 | } catch (IllegalArgumentException e) { |
| 597 | throw new IllegalArgumentException("Invalid action string"); |
| 598 | } |
| 599 | } else { |
| 600 | throw new IllegalArgumentException("Invalid action string"); |
| 601 | } |
| 602 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 603 | } |
| 604 | |
| 605 | /** |
| 606 | * Action structure for ACTION_SET_NW_SRC and ACTION_SET_NW_DST: |
| 607 | * Set the IPv4 source/destination address. |
| 608 | */ |
Yuta HIGUCHI | 382827f | 2013-10-14 16:06:43 -0700 | [diff] [blame] | 609 | public static class ActionSetIPv4Addr { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 610 | private IPv4 addr; // The IPv4 address to set |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 611 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 612 | /** |
| 613 | * Default constructor. |
| 614 | */ |
| 615 | public ActionSetIPv4Addr() { |
| 616 | this.addr = null; |
| 617 | } |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 618 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 619 | /** |
| 620 | * Copy constructor. |
| 621 | * |
| 622 | * @param other the object to copy from. |
| 623 | */ |
| 624 | public ActionSetIPv4Addr(ActionSetIPv4Addr other) { |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 625 | if (other.addr != null) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 626 | this.addr = new IPv4(other.addr); |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 627 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 628 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 629 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 630 | /** |
| 631 | * Constructor from a string. |
| 632 | * <p/> |
| 633 | * The string has the following form: |
| 634 | * [addr=XXX] |
| 635 | * |
| 636 | * @param actionStr the action as a string. |
| 637 | */ |
| 638 | public ActionSetIPv4Addr(String actionStr) { |
| 639 | this.fromString(actionStr); |
| 640 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 641 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 642 | /** |
| 643 | * Constructor for a given IPv4 address. |
| 644 | * |
| 645 | * @param addr the IPv4 address to set. |
| 646 | */ |
| 647 | public ActionSetIPv4Addr(IPv4 addr) { |
| 648 | this.addr = addr; |
| 649 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 650 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 651 | /** |
| 652 | * Get the IPv4 address. |
| 653 | * |
| 654 | * @return the IPv4 address. |
| 655 | */ |
| 656 | @JsonProperty("addr") |
| 657 | public IPv4 addr() { |
| 658 | return this.addr; |
| 659 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 660 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 661 | /** |
| 662 | * Convert the action to a string. |
| 663 | * <p/> |
| 664 | * The string has the following form: |
| 665 | * [addr=XXX] |
| 666 | * |
| 667 | * @return the action as a string. |
| 668 | */ |
| 669 | @Override |
| 670 | public String toString() { |
| 671 | String ret = "["; |
| 672 | ret += "addr=" + addr.toString(); |
| 673 | ret += "]"; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 674 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 675 | return ret; |
| 676 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 677 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 678 | /** |
| 679 | * Convert a string to an action. |
| 680 | * <p/> |
| 681 | * The string has the following form: |
| 682 | * [addr=XXX] |
| 683 | * |
| 684 | * @param actionStr the action as a string. |
| 685 | */ |
| 686 | public void fromString(String actionStr) { |
| 687 | String[] parts = actionStr.split("addr="); |
| 688 | String decode = null; |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 689 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 690 | // Decode the value |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 691 | if (parts.length > 1) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 692 | decode = parts[1]; |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 693 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 694 | if (decode != null) { |
| 695 | decode = decode.replace("]", ""); |
| 696 | try { |
| 697 | addr = new IPv4(decode); |
| 698 | } catch (IllegalArgumentException e) { |
| 699 | throw new IllegalArgumentException("Invalid action string"); |
| 700 | } |
| 701 | } else { |
| 702 | throw new IllegalArgumentException("Invalid action string"); |
| 703 | } |
| 704 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 705 | } |
| 706 | |
| 707 | /** |
| 708 | * Action structure for ACTION_SET_NW_TOS: |
| 709 | * Set the IP ToS (DSCP field, 6 bits). |
| 710 | */ |
Yuta HIGUCHI | 382827f | 2013-10-14 16:06:43 -0700 | [diff] [blame] | 711 | public static class ActionSetIpToS { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 712 | private byte ipToS; // The IP ToS to set DSCP field, 6 bits) |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 713 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 714 | /** |
| 715 | * Default constructor. |
| 716 | */ |
| 717 | public ActionSetIpToS() { |
| 718 | this.ipToS = 0; |
| 719 | } |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 720 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 721 | /** |
| 722 | * Copy constructor. |
| 723 | * |
| 724 | * @param other the object to copy from. |
| 725 | */ |
| 726 | public ActionSetIpToS(ActionSetIpToS other) { |
| 727 | this.ipToS = other.ipToS; |
| 728 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 729 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 730 | /** |
| 731 | * Constructor from a string. |
| 732 | * <p/> |
| 733 | * The string has the following form: |
| 734 | * [ipToS=XXX] |
| 735 | * |
| 736 | * @param actionStr the action as a string. |
| 737 | */ |
| 738 | public ActionSetIpToS(String actionStr) { |
| 739 | this.fromString(actionStr); |
| 740 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 741 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 742 | /** |
| 743 | * Constructor for a given IP ToS (DSCP field, 6 bits). |
| 744 | * |
| 745 | * @param ipToS the IP ToS (DSCP field, 6 bits) to set. |
| 746 | */ |
| 747 | public ActionSetIpToS(byte ipToS) { |
| 748 | this.ipToS = ipToS; |
| 749 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 750 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 751 | /** |
| 752 | * Get the IP ToS (DSCP field, 6 bits). |
| 753 | * |
| 754 | * @return the IP ToS (DSCP field, 6 bits). |
| 755 | */ |
| 756 | @JsonProperty("ipToS") |
| 757 | public byte ipToS() { |
| 758 | return this.ipToS; |
| 759 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 760 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 761 | /** |
| 762 | * Convert the action to a string. |
| 763 | * <p/> |
| 764 | * The string has the following form: |
| 765 | * [ipToS=XXX] |
| 766 | * |
| 767 | * @return the action as a string. |
| 768 | */ |
| 769 | @Override |
| 770 | public String toString() { |
| 771 | String ret = "["; |
| 772 | ret += "ipToS=" + ipToS; |
| 773 | ret += "]"; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 774 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 775 | return ret; |
| 776 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 777 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 778 | /** |
| 779 | * Convert a string to an action. |
| 780 | * <p/> |
| 781 | * The string has the following form: |
| 782 | * [ipToS=XXX] |
| 783 | * |
| 784 | * @param actionStr the action as a string. |
| 785 | */ |
| 786 | public void fromString(String actionStr) { |
| 787 | String[] parts = actionStr.split("ipToS="); |
| 788 | String decode = null; |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 789 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 790 | // Decode the value |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 791 | if (parts.length > 1) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 792 | decode = parts[1]; |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 793 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 794 | if (decode != null) { |
| 795 | decode = decode.replace("]", ""); |
| 796 | try { |
| 797 | ipToS = Byte.valueOf(decode); |
| 798 | } catch (NumberFormatException e) { |
| 799 | throw new IllegalArgumentException("Invalid action string"); |
| 800 | } |
| 801 | } else { |
| 802 | throw new IllegalArgumentException("Invalid action string"); |
| 803 | } |
| 804 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 805 | } |
| 806 | |
| 807 | /** |
| 808 | * Action structure for ACTION_SET_TP_SRC and ACTION_SET_TP_DST: |
| 809 | * Set the TCP/UDP source/destination port. |
| 810 | */ |
Yuta HIGUCHI | 382827f | 2013-10-14 16:06:43 -0700 | [diff] [blame] | 811 | public static class ActionSetTcpUdpPort { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 812 | private short port; // The TCP/UDP port to set |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 813 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 814 | /** |
| 815 | * Default constructor. |
| 816 | */ |
| 817 | public ActionSetTcpUdpPort() { |
| 818 | this.port = 0; |
| 819 | } |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 820 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 821 | /** |
| 822 | * Copy constructor. |
| 823 | * |
| 824 | * @param other the object to copy from. |
| 825 | */ |
| 826 | public ActionSetTcpUdpPort(ActionSetTcpUdpPort other) { |
| 827 | this.port = other.port; |
| 828 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 829 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 830 | /** |
| 831 | * Constructor from a string. |
| 832 | * <p/> |
| 833 | * The string has the following form: |
| 834 | * [port=XXX] |
| 835 | * |
| 836 | * @param actionStr the action as a string. |
| 837 | */ |
| 838 | public ActionSetTcpUdpPort(String actionStr) { |
| 839 | this.fromString(actionStr); |
| 840 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 841 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 842 | /** |
| 843 | * Constructor for a given TCP/UDP port. |
| 844 | * |
| 845 | * @param port the TCP/UDP port to set. |
| 846 | */ |
| 847 | public ActionSetTcpUdpPort(short port) { |
| 848 | this.port = port; |
| 849 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 850 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 851 | /** |
| 852 | * Get the TCP/UDP port. |
| 853 | * |
| 854 | * @return the TCP/UDP port. |
| 855 | */ |
| 856 | @JsonProperty("port") |
| 857 | public short port() { |
| 858 | return this.port; |
| 859 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 860 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 861 | /** |
| 862 | * Convert the action to a string. |
| 863 | * <p/> |
| 864 | * The string has the following form: |
| 865 | * [port=XXX] |
| 866 | * |
| 867 | * @return the action as a string. |
| 868 | */ |
| 869 | @Override |
| 870 | public String toString() { |
| 871 | String ret = "["; |
| 872 | ret += "port=" + port; |
| 873 | ret += "]"; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 874 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 875 | return ret; |
| 876 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 877 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 878 | /** |
| 879 | * Convert a string to an action. |
| 880 | * <p/> |
| 881 | * The string has the following form: |
| 882 | * [port=XXX] |
| 883 | * |
| 884 | * @param actionStr the action as a string. |
| 885 | */ |
| 886 | public void fromString(String actionStr) { |
| 887 | String[] parts = actionStr.split("port="); |
| 888 | String decode = null; |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 889 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 890 | // Decode the value |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 891 | if (parts.length > 1) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 892 | decode = parts[1]; |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 893 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 894 | if (decode != null) { |
| 895 | decode = decode.replace("]", ""); |
| 896 | try { |
| 897 | port = Short.valueOf(decode); |
| 898 | } catch (NumberFormatException e) { |
| 899 | throw new IllegalArgumentException("Invalid action string"); |
| 900 | } |
| 901 | } else { |
| 902 | throw new IllegalArgumentException("Invalid action string"); |
| 903 | } |
| 904 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 905 | } |
| 906 | |
| 907 | /** |
| 908 | * Action structure for ACTION_ENQUEUE: Output to queue on port. |
| 909 | */ |
Yuta HIGUCHI | 382827f | 2013-10-14 16:06:43 -0700 | [diff] [blame] | 910 | public static class ActionEnqueue { |
Yuta HIGUCHI | fb56450 | 2014-06-16 21:29:00 -0700 | [diff] [blame] | 911 | private PortNumber port; // Port that queue belongs. Should |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 912 | // refer to a valid physical port |
| 913 | // (i.e. < PORT_MAX) or PORT_IN_PORT |
| 914 | private int queueId; // Where to enqueue the packets |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 915 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 916 | /** |
| 917 | * Default constructor. |
| 918 | */ |
| 919 | public ActionEnqueue() { |
| 920 | this.port = null; |
| 921 | this.queueId = 0; |
| 922 | } |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 923 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 924 | /** |
| 925 | * Copy constructor. |
| 926 | * |
| 927 | * @param other the object to copy from. |
| 928 | */ |
| 929 | public ActionEnqueue(ActionEnqueue other) { |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 930 | if (other.port != null) { |
Yuta HIGUCHI | fb56450 | 2014-06-16 21:29:00 -0700 | [diff] [blame] | 931 | this.port = new PortNumber(other.port); |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 932 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 933 | this.queueId = other.queueId; |
| 934 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 935 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 936 | /** |
| 937 | * Constructor from a string. |
| 938 | * <p/> |
| 939 | * The string has the following form: |
| 940 | * [port=XXX queueId=XXX] |
| 941 | * |
| 942 | * @param actionStr the action as a string. |
| 943 | */ |
| 944 | public ActionEnqueue(String actionStr) { |
| 945 | this.fromString(actionStr); |
| 946 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 947 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 948 | /** |
| 949 | * Constructor for a given port and queue ID. |
| 950 | * |
| 951 | * @param port the port to set. |
| 952 | * @param queueId the queue ID on the port. |
| 953 | */ |
Yuta HIGUCHI | fb56450 | 2014-06-16 21:29:00 -0700 | [diff] [blame] | 954 | public ActionEnqueue(PortNumber port, int queueId) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 955 | this.port = port; |
| 956 | this.queueId = queueId; |
| 957 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 958 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 959 | /** |
| 960 | * Get the port. |
| 961 | * |
| 962 | * @return the port. |
| 963 | */ |
| 964 | @JsonProperty("port") |
Yuta HIGUCHI | fb56450 | 2014-06-16 21:29:00 -0700 | [diff] [blame] | 965 | public PortNumber port() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 966 | return this.port; |
| 967 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 968 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 969 | /** |
| 970 | * Get the queue ID. |
| 971 | * |
| 972 | * @return the queue ID. |
| 973 | */ |
| 974 | @JsonProperty("queueId") |
| 975 | public int queueId() { |
| 976 | return this.queueId; |
| 977 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 978 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 979 | /** |
| 980 | * Convert the action to a string. |
| 981 | * <p/> |
| 982 | * The string has the following form: |
| 983 | * [port=XXX queueId=XXX] |
| 984 | * |
| 985 | * @return the action as a string. |
| 986 | */ |
| 987 | @Override |
| 988 | public String toString() { |
| 989 | String ret = "["; |
| 990 | ret += "port=" + port.toString(); |
| 991 | ret += " queueId=" + queueId; |
| 992 | ret += "]"; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 993 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 994 | return ret; |
| 995 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 996 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 997 | /** |
| 998 | * Convert a string to an action. |
| 999 | * <p/> |
| 1000 | * The string has the following form: |
| 1001 | * [port=XXX queueId=XXX] |
| 1002 | * |
| 1003 | * @param actionStr the action as a string. |
| 1004 | */ |
| 1005 | public void fromString(String actionStr) { |
| 1006 | String[] parts = actionStr.split(" "); |
| 1007 | String decode = null; |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 1008 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1009 | // Decode the "port=XXX" part |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1010 | if (parts.length > 0) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1011 | decode = parts[0]; |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1012 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1013 | if (decode != null) { |
| 1014 | String[] tokens = decode.split("port="); |
| 1015 | if (tokens.length > 1 && tokens[1] != null) { |
| 1016 | try { |
| 1017 | Short valueShort = Short.valueOf(tokens[1]); |
Yuta HIGUCHI | fb56450 | 2014-06-16 21:29:00 -0700 | [diff] [blame] | 1018 | port = new PortNumber(valueShort); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1019 | } catch (NumberFormatException e) { |
| 1020 | throw new IllegalArgumentException("Invalid action string"); |
| 1021 | } |
| 1022 | } |
| 1023 | } else { |
| 1024 | throw new IllegalArgumentException("Invalid action string"); |
| 1025 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 1026 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1027 | // Decode the "queueId=XXX" part |
| 1028 | decode = null; |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1029 | if (parts.length > 1) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1030 | decode = parts[1]; |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1031 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1032 | if (decode != null) { |
| 1033 | decode = decode.replace("]", ""); |
| 1034 | String[] tokens = decode.split("queueId="); |
| 1035 | if (tokens.length > 1 && tokens[1] != null) { |
| 1036 | try { |
| 1037 | queueId = Short.valueOf(tokens[1]); |
| 1038 | } catch (NumberFormatException e) { |
| 1039 | throw new IllegalArgumentException("Invalid action string"); |
| 1040 | } |
| 1041 | } |
| 1042 | } else { |
| 1043 | throw new IllegalArgumentException("Invalid action string"); |
| 1044 | } |
| 1045 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1046 | } |
| 1047 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1048 | private ActionValues actionType; // The action type |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1049 | |
| 1050 | // |
| 1051 | // The actions. |
| 1052 | // NOTE: Only one action should be set. |
| 1053 | // |
| 1054 | private ActionOutput actionOutput; |
| 1055 | private ActionSetVlanId actionSetVlanId; |
| 1056 | private ActionSetVlanPriority actionSetVlanPriority; |
| 1057 | private ActionStripVlan actionStripVlan; |
| 1058 | private ActionSetEthernetAddr actionSetEthernetSrcAddr; |
| 1059 | private ActionSetEthernetAddr actionSetEthernetDstAddr; |
| 1060 | private ActionSetIPv4Addr actionSetIPv4SrcAddr; |
| 1061 | private ActionSetIPv4Addr actionSetIPv4DstAddr; |
| 1062 | private ActionSetIpToS actionSetIpToS; |
| 1063 | private ActionSetTcpUdpPort actionSetTcpUdpSrcPort; |
| 1064 | private ActionSetTcpUdpPort actionSetTcpUdpDstPort; |
| 1065 | private ActionEnqueue actionEnqueue; |
| 1066 | |
| 1067 | /** |
| 1068 | * Default constructor. |
| 1069 | */ |
| 1070 | public FlowEntryAction() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1071 | actionType = ActionValues.ACTION_VENDOR; // XXX: Initial value |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1072 | } |
| 1073 | |
| 1074 | /** |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 1075 | * Copy constructor. |
| 1076 | * |
| 1077 | * @param other the object to copy from. |
| 1078 | */ |
| 1079 | public FlowEntryAction(FlowEntryAction other) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1080 | this.actionType = other.actionType; |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 1081 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1082 | // |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1083 | if (other.actionOutput != null) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1084 | this.actionOutput = new ActionOutput(other.actionOutput); |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1085 | } else { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1086 | this.actionOutput = null; |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1087 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1088 | // |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1089 | if (other.actionSetVlanId != null) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1090 | this.actionSetVlanId = new ActionSetVlanId(other.actionSetVlanId); |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1091 | } else { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1092 | this.actionSetVlanId = null; |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1093 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1094 | // |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1095 | if (other.actionSetVlanPriority != null) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1096 | this.actionSetVlanPriority = new ActionSetVlanPriority(other.actionSetVlanPriority); |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1097 | } else { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1098 | this.actionSetVlanPriority = null; |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1099 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1100 | // |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1101 | if (other.actionStripVlan != null) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1102 | this.actionStripVlan = new ActionStripVlan(other.actionStripVlan); |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1103 | } else { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1104 | this.actionStripVlan = null; |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1105 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1106 | // |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1107 | if (other.actionSetEthernetSrcAddr != null) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1108 | this.actionSetEthernetSrcAddr = new ActionSetEthernetAddr(other.actionSetEthernetSrcAddr); |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1109 | } else { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1110 | this.actionSetEthernetSrcAddr = null; |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1111 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1112 | // |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1113 | if (other.actionSetEthernetDstAddr != null) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1114 | this.actionSetEthernetDstAddr = new ActionSetEthernetAddr(other.actionSetEthernetDstAddr); |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1115 | } else { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1116 | this.actionSetEthernetDstAddr = null; |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1117 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1118 | // |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1119 | if (other.actionSetIPv4SrcAddr != null) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1120 | this.actionSetIPv4SrcAddr = new ActionSetIPv4Addr(other.actionSetIPv4SrcAddr); |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1121 | } else { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1122 | this.actionSetIPv4SrcAddr = null; |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1123 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1124 | // |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1125 | if (other.actionSetIPv4DstAddr != null) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1126 | this.actionSetIPv4DstAddr = new ActionSetIPv4Addr(other.actionSetIPv4DstAddr); |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1127 | } else { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1128 | this.actionSetIPv4DstAddr = null; |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1129 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1130 | // |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1131 | if (other.actionSetIpToS != null) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1132 | this.actionSetIpToS = new ActionSetIpToS(other.actionSetIpToS); |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1133 | } else { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1134 | this.actionSetIpToS = null; |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1135 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1136 | // |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1137 | if (other.actionSetTcpUdpSrcPort != null) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1138 | this.actionSetTcpUdpSrcPort = new ActionSetTcpUdpPort(other.actionSetTcpUdpSrcPort); |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1139 | } else { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1140 | this.actionSetTcpUdpSrcPort = null; |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1141 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1142 | // |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1143 | if (other.actionSetTcpUdpDstPort != null) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1144 | this.actionSetTcpUdpDstPort = new ActionSetTcpUdpPort(other.actionSetTcpUdpDstPort); |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1145 | } else { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1146 | this.actionSetTcpUdpDstPort = null; |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1147 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1148 | // |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1149 | if (other.actionEnqueue != null) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1150 | this.actionEnqueue = new ActionEnqueue(other.actionEnqueue); |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1151 | } else { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1152 | this.actionEnqueue = null; |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1153 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 1154 | } |
| 1155 | |
| 1156 | /** |
| 1157 | * Constructor from a string. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1158 | * <p/> |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 1159 | * The string has the following form: |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1160 | * [type=XXX action=XXX] |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 1161 | * |
| 1162 | * @param actionStr the action as a string. |
| 1163 | */ |
| 1164 | public FlowEntryAction(String actionStr) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1165 | this.fromString(actionStr); |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 1166 | } |
| 1167 | |
| 1168 | /** |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1169 | * Get the action type. |
| 1170 | * |
| 1171 | * @return the action type. |
| 1172 | */ |
| 1173 | @JsonProperty("actionType") |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1174 | public ActionValues actionType() { |
| 1175 | return actionType; |
| 1176 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1177 | |
| 1178 | /** |
| 1179 | * Get the output action. |
| 1180 | * |
| 1181 | * @return the output action. |
| 1182 | */ |
| 1183 | @JsonProperty("actionOutput") |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1184 | public ActionOutput actionOutput() { |
| 1185 | return actionOutput; |
| 1186 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1187 | |
| 1188 | /** |
| 1189 | * Set the output action on a port. |
| 1190 | * |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1191 | * @param action the action to set. |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1192 | */ |
| 1193 | @JsonProperty("actionOutput") |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1194 | public void setActionOutput(ActionOutput action) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1195 | actionOutput = action; |
| 1196 | actionType = ActionValues.ACTION_OUTPUT; |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1197 | } |
| 1198 | |
| 1199 | /** |
| 1200 | * Set the output action on a port. |
| 1201 | * |
| 1202 | * @param port the output port to set. |
| 1203 | */ |
Yuta HIGUCHI | fb56450 | 2014-06-16 21:29:00 -0700 | [diff] [blame] | 1204 | public void setActionOutput(PortNumber port) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1205 | actionOutput = new ActionOutput(port); |
| 1206 | actionType = ActionValues.ACTION_OUTPUT; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1207 | } |
| 1208 | |
| 1209 | /** |
| 1210 | * Set the output action to controller. |
| 1211 | * |
| 1212 | * @param maxLen the maximum length (in bytes) to send to controller. |
| 1213 | */ |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1214 | public void setActionOutputToController(short maxLen) { |
Yuta HIGUCHI | fb56450 | 2014-06-16 21:29:00 -0700 | [diff] [blame] | 1215 | PortNumber port = new PortNumber(PortNumber.PortValues.PORT_CONTROLLER); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1216 | actionOutput = new ActionOutput(port, maxLen); |
| 1217 | actionType = ActionValues.ACTION_OUTPUT; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1218 | } |
| 1219 | |
| 1220 | /** |
| 1221 | * Get the action to set the VLAN ID. |
| 1222 | * |
| 1223 | * @return the action to set the VLAN ID. |
| 1224 | */ |
| 1225 | @JsonProperty("actionSetVlanId") |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1226 | public ActionSetVlanId actionSetVlanId() { |
| 1227 | return actionSetVlanId; |
| 1228 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1229 | |
| 1230 | /** |
| 1231 | * Set the action to set the VLAN ID. |
| 1232 | * |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1233 | * @param action the action to set. |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1234 | */ |
| 1235 | @JsonProperty("actionSetVlanId") |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1236 | public void setActionSetVlanId(ActionSetVlanId action) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1237 | actionSetVlanId = action; |
| 1238 | actionType = ActionValues.ACTION_SET_VLAN_VID; |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1239 | } |
| 1240 | |
| 1241 | /** |
| 1242 | * Set the action to set the VLAN ID. |
| 1243 | * |
| 1244 | * @param vlanId the VLAN ID to set. |
| 1245 | */ |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1246 | public void setActionSetVlanId(short vlanId) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1247 | actionSetVlanId = new ActionSetVlanId(vlanId); |
| 1248 | actionType = ActionValues.ACTION_SET_VLAN_VID; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1249 | } |
| 1250 | |
| 1251 | /** |
| 1252 | * Get the action to set the VLAN priority. |
| 1253 | * |
| 1254 | * @return the action to set the VLAN priority. |
| 1255 | */ |
| 1256 | @JsonProperty("actionSetVlanPriority") |
| 1257 | public ActionSetVlanPriority actionSetVlanPriority() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1258 | return actionSetVlanPriority; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1259 | } |
| 1260 | |
| 1261 | /** |
| 1262 | * Set the action to set the VLAN priority. |
| 1263 | * |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1264 | * @param action the action to set. |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1265 | */ |
| 1266 | @JsonProperty("actionSetVlanPriority") |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1267 | public void setActionSetVlanPriority(ActionSetVlanPriority action) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1268 | actionSetVlanPriority = action; |
| 1269 | actionType = ActionValues.ACTION_SET_VLAN_PCP; |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1270 | } |
| 1271 | |
| 1272 | /** |
| 1273 | * Set the action to set the VLAN priority. |
| 1274 | * |
| 1275 | * @param vlanPriority the VLAN priority to set. |
| 1276 | */ |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1277 | public void setActionSetVlanPriority(byte vlanPriority) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1278 | actionSetVlanPriority = new ActionSetVlanPriority(vlanPriority); |
| 1279 | actionType = ActionValues.ACTION_SET_VLAN_PCP; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1280 | } |
| 1281 | |
| 1282 | /** |
| 1283 | * Get the action to strip the VLAN header. |
| 1284 | * |
| 1285 | * @return the action to strip the VLAN header. |
| 1286 | */ |
| 1287 | @JsonProperty("actionStripVlan") |
| 1288 | public ActionStripVlan actionStripVlan() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1289 | return actionStripVlan; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1290 | } |
| 1291 | |
| 1292 | /** |
| 1293 | * Set the action to strip the VLAN header. |
| 1294 | * |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1295 | * @param action the action to set. |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1296 | */ |
| 1297 | @JsonProperty("actionStripVlan") |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1298 | public void setActionStripVlan(ActionStripVlan action) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1299 | actionStripVlan = action; |
| 1300 | actionType = ActionValues.ACTION_STRIP_VLAN; |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1301 | } |
| 1302 | |
| 1303 | /** |
| 1304 | * Set the action to strip the VLAN header. |
| 1305 | * |
| 1306 | * @param stripVlan if true, strip the VLAN header. |
| 1307 | */ |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1308 | public void setActionStripVlan(boolean stripVlan) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1309 | actionStripVlan = new ActionStripVlan(stripVlan); |
| 1310 | actionType = ActionValues.ACTION_STRIP_VLAN; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1311 | } |
| 1312 | |
| 1313 | /** |
| 1314 | * Get the action to set the Ethernet source address. |
| 1315 | * |
| 1316 | * @return the action to set the Ethernet source address. |
| 1317 | */ |
| 1318 | @JsonProperty("actionSetEthernetSrcAddr") |
| 1319 | public ActionSetEthernetAddr actionSetEthernetSrcAddr() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1320 | return actionSetEthernetSrcAddr; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1321 | } |
| 1322 | |
| 1323 | /** |
| 1324 | * Set the action to set the Ethernet source address. |
| 1325 | * |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1326 | * @param action the action to set. |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1327 | */ |
| 1328 | @JsonProperty("actionSetEthernetSrcAddr") |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1329 | public void setActionSetEthernetSrcAddr(ActionSetEthernetAddr action) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1330 | actionSetEthernetSrcAddr = action; |
| 1331 | actionType = ActionValues.ACTION_SET_DL_SRC; |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1332 | } |
| 1333 | |
| 1334 | /** |
| 1335 | * Set the action to set the Ethernet source address. |
| 1336 | * |
| 1337 | * @param addr the MAC address to set as the Ethernet source address. |
| 1338 | */ |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1339 | public void setActionSetEthernetSrcAddr(MACAddress addr) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1340 | actionSetEthernetSrcAddr = new ActionSetEthernetAddr(addr); |
| 1341 | actionType = ActionValues.ACTION_SET_DL_SRC; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1342 | } |
| 1343 | |
| 1344 | /** |
| 1345 | * Get the action to set the Ethernet destination address. |
| 1346 | * |
| 1347 | * @return the action to set the Ethernet destination address. |
| 1348 | */ |
| 1349 | @JsonProperty("actionSetEthernetDstAddr") |
| 1350 | public ActionSetEthernetAddr actionSetEthernetDstAddr() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1351 | return actionSetEthernetDstAddr; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1352 | } |
| 1353 | |
| 1354 | /** |
| 1355 | * Set the action to set the Ethernet destination address. |
| 1356 | * |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1357 | * @param action the action to set. |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1358 | */ |
| 1359 | @JsonProperty("actionSetEthernetDstAddr") |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1360 | public void setActionSetEthernetDstAddr(ActionSetEthernetAddr action) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1361 | actionSetEthernetDstAddr = action; |
| 1362 | actionType = ActionValues.ACTION_SET_DL_DST; |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1363 | } |
| 1364 | |
| 1365 | /** |
| 1366 | * Set the action to set the Ethernet destination address. |
| 1367 | * |
| 1368 | * @param addr the MAC address to set as the Ethernet destination address. |
| 1369 | */ |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1370 | public void setActionSetEthernetDstAddr(MACAddress addr) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1371 | actionSetEthernetDstAddr = new ActionSetEthernetAddr(addr); |
| 1372 | actionType = ActionValues.ACTION_SET_DL_DST; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1373 | } |
| 1374 | |
| 1375 | /** |
| 1376 | * Get the action to set the IPv4 source address. |
| 1377 | * |
| 1378 | * @return the action to set the IPv4 source address. |
| 1379 | */ |
| 1380 | @JsonProperty("actionSetIPv4SrcAddr") |
| 1381 | public ActionSetIPv4Addr actionSetIPv4SrcAddr() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1382 | return actionSetIPv4SrcAddr; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1383 | } |
| 1384 | |
| 1385 | /** |
| 1386 | * Set the action to set the IPv4 source address. |
| 1387 | * |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1388 | * @param action the action to set. |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1389 | */ |
| 1390 | @JsonProperty("actionSetIPv4SrcAddr") |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1391 | public void setActionSetIPv4SrcAddr(ActionSetIPv4Addr action) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1392 | actionSetIPv4SrcAddr = action; |
| 1393 | actionType = ActionValues.ACTION_SET_NW_SRC; |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1394 | } |
| 1395 | |
| 1396 | /** |
| 1397 | * Set the action to set the IPv4 source address. |
| 1398 | * |
| 1399 | * @param addr the IPv4 address to set as the IPv4 source address. |
| 1400 | */ |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1401 | public void setActionSetIPv4SrcAddr(IPv4 addr) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1402 | actionSetIPv4SrcAddr = new ActionSetIPv4Addr(addr); |
| 1403 | actionType = ActionValues.ACTION_SET_NW_SRC; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1404 | } |
| 1405 | |
| 1406 | /** |
| 1407 | * Get the action to set the IPv4 destination address. |
| 1408 | * |
| 1409 | * @return the action to set the IPv4 destination address. |
| 1410 | */ |
| 1411 | @JsonProperty("actionSetIPv4DstAddr") |
| 1412 | public ActionSetIPv4Addr actionSetIPv4DstAddr() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1413 | return actionSetIPv4DstAddr; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1414 | } |
| 1415 | |
| 1416 | /** |
| 1417 | * Set the action to set the IPv4 destination address. |
| 1418 | * |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1419 | * @param action the action to set. |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1420 | */ |
| 1421 | @JsonProperty("actionSetIPv4DstAddr") |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1422 | public void setActionSetIPv4DstAddr(ActionSetIPv4Addr action) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1423 | actionSetIPv4DstAddr = action; |
| 1424 | actionType = ActionValues.ACTION_SET_NW_DST; |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1425 | } |
| 1426 | |
| 1427 | /** |
| 1428 | * Set the action to set the IPv4 destination address. |
| 1429 | * |
| 1430 | * @param addr the IPv4 address to set as the IPv4 destination address. |
| 1431 | */ |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1432 | public void setActionSetIPv4DstAddr(IPv4 addr) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1433 | actionSetIPv4DstAddr = new ActionSetIPv4Addr(addr); |
| 1434 | actionType = ActionValues.ACTION_SET_NW_DST; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1435 | } |
| 1436 | |
| 1437 | /** |
| 1438 | * Get the action to set the IP ToS (DSCP field, 6 bits). |
| 1439 | * |
| 1440 | * @return the action to set the IP ToS (DSCP field, 6 bits). |
| 1441 | */ |
| 1442 | @JsonProperty("actionSetIpToS") |
| 1443 | public ActionSetIpToS actionSetIpToS() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1444 | return actionSetIpToS; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1445 | } |
| 1446 | |
| 1447 | /** |
| 1448 | * Set the action to set the IP ToS (DSCP field, 6 bits). |
| 1449 | * |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1450 | * @param action the action to set. |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1451 | */ |
| 1452 | @JsonProperty("actionSetIpToS") |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1453 | public void setActionSetIpToS(ActionSetIpToS action) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1454 | actionSetIpToS = action; |
| 1455 | actionType = ActionValues.ACTION_SET_NW_TOS; |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1456 | } |
| 1457 | |
| 1458 | /** |
| 1459 | * Set the action to set the IP ToS (DSCP field, 6 bits). |
| 1460 | * |
| 1461 | * @param ipToS the IP ToS (DSCP field, 6 bits) to set. |
| 1462 | */ |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1463 | public void setActionSetIpToS(byte ipToS) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1464 | actionSetIpToS = new ActionSetIpToS(ipToS); |
| 1465 | actionType = ActionValues.ACTION_SET_NW_TOS; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1466 | } |
| 1467 | |
| 1468 | /** |
| 1469 | * Get the action to set the TCP/UDP source port. |
| 1470 | * |
| 1471 | * @return the action to set the TCP/UDP source port. |
| 1472 | */ |
| 1473 | @JsonProperty("actionSetTcpUdpSrcPort") |
| 1474 | public ActionSetTcpUdpPort actionSetTcpUdpSrcPort() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1475 | return actionSetTcpUdpSrcPort; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1476 | } |
| 1477 | |
| 1478 | /** |
| 1479 | * Set the action to set the TCP/UDP source port. |
| 1480 | * |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1481 | * @param action the action to set. |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1482 | */ |
| 1483 | @JsonProperty("actionSetTcpUdpSrcPort") |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1484 | public void setActionSetTcpUdpSrcPort(ActionSetTcpUdpPort action) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1485 | actionSetTcpUdpSrcPort = action; |
| 1486 | actionType = ActionValues.ACTION_SET_TP_SRC; |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1487 | } |
| 1488 | |
| 1489 | /** |
| 1490 | * Set the action to set the TCP/UDP source port. |
| 1491 | * |
| 1492 | * @param port the TCP/UDP port to set as the TCP/UDP source port. |
| 1493 | */ |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1494 | public void setActionSetTcpUdpSrcPort(short port) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1495 | actionSetTcpUdpSrcPort = new ActionSetTcpUdpPort(port); |
| 1496 | actionType = ActionValues.ACTION_SET_TP_SRC; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1497 | } |
| 1498 | |
| 1499 | /** |
| 1500 | * Get the action to set the TCP/UDP destination port. |
| 1501 | * |
| 1502 | * @return the action to set the TCP/UDP destination port. |
| 1503 | */ |
| 1504 | @JsonProperty("actionSetTcpUdpDstPort") |
| 1505 | public ActionSetTcpUdpPort actionSetTcpUdpDstPort() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1506 | return actionSetTcpUdpDstPort; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1507 | } |
| 1508 | |
| 1509 | /** |
| 1510 | * Set the action to set the TCP/UDP destination port. |
| 1511 | * |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1512 | * @param action the action to set. |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1513 | */ |
| 1514 | @JsonProperty("actionSetTcpUdpDstPort") |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1515 | public void setActionSetTcpUdpDstPort(ActionSetTcpUdpPort action) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1516 | actionSetTcpUdpDstPort = action; |
| 1517 | actionType = ActionValues.ACTION_SET_TP_DST; |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1518 | } |
| 1519 | |
| 1520 | /** |
| 1521 | * Set the action to set the TCP/UDP destination port. |
| 1522 | * |
| 1523 | * @param port the TCP/UDP port to set as the TCP/UDP destination port. |
| 1524 | */ |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1525 | public void setActionSetTcpUdpDstPort(short port) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1526 | actionSetTcpUdpDstPort = new ActionSetTcpUdpPort(port); |
| 1527 | actionType = ActionValues.ACTION_SET_TP_DST; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1528 | } |
| 1529 | |
| 1530 | /** |
| 1531 | * Get the action to output to queue on a port. |
| 1532 | * |
| 1533 | * @return the action to output to queue on a port. |
| 1534 | */ |
| 1535 | @JsonProperty("actionEnqueue") |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1536 | public ActionEnqueue actionEnqueue() { |
| 1537 | return actionEnqueue; |
| 1538 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1539 | |
| 1540 | /** |
| 1541 | * Set the action to output to queue on a port. |
| 1542 | * |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1543 | * @param action the action to set. |
| 1544 | */ |
| 1545 | @JsonProperty("actionEnqueue") |
| 1546 | public void setActionEnqueue(ActionEnqueue action) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1547 | actionEnqueue = action; |
| 1548 | actionType = ActionValues.ACTION_ENQUEUE; |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 1549 | } |
| 1550 | |
| 1551 | /** |
| 1552 | * Set the action to output to queue on a port. |
| 1553 | * |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1554 | * @param port the port to set. |
HIGUCHI Yuta | eb567aa | 2013-10-08 19:27:35 -0700 | [diff] [blame] | 1555 | * @param queueId the queue ID to set. |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1556 | */ |
Yuta HIGUCHI | fb56450 | 2014-06-16 21:29:00 -0700 | [diff] [blame] | 1557 | public void setActionEnqueue(PortNumber port, int queueId) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1558 | actionEnqueue = new ActionEnqueue(port, queueId); |
| 1559 | actionType = ActionValues.ACTION_ENQUEUE; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1560 | } |
| 1561 | |
| 1562 | /** |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 1563 | * Convert the action to a string. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1564 | * <p/> |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1565 | * The string has the following form: |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1566 | * [type=XXX action=XXX] |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1567 | * |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 1568 | * @return the action as a string. |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1569 | */ |
| 1570 | @Override |
| 1571 | public String toString() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1572 | String ret = "["; |
| 1573 | ret += "type=" + actionType; |
| 1574 | switch (actionType) { |
| 1575 | case ACTION_OUTPUT: |
| 1576 | ret += " action=" + actionOutput.toString(); |
| 1577 | break; |
| 1578 | case ACTION_SET_VLAN_VID: |
| 1579 | ret += " action=" + actionSetVlanId.toString(); |
| 1580 | break; |
| 1581 | case ACTION_SET_VLAN_PCP: |
| 1582 | ret += " action=" + actionSetVlanPriority.toString(); |
| 1583 | break; |
| 1584 | case ACTION_STRIP_VLAN: |
| 1585 | ret += " action=" + actionStripVlan.toString(); |
| 1586 | break; |
| 1587 | case ACTION_SET_DL_SRC: |
| 1588 | ret += " action=" + actionSetEthernetSrcAddr.toString(); |
| 1589 | break; |
| 1590 | case ACTION_SET_DL_DST: |
| 1591 | ret += " action=" + actionSetEthernetDstAddr.toString(); |
| 1592 | break; |
| 1593 | case ACTION_SET_NW_SRC: |
| 1594 | ret += " action=" + actionSetIPv4SrcAddr.toString(); |
| 1595 | break; |
| 1596 | case ACTION_SET_NW_DST: |
| 1597 | ret += " action=" + actionSetIPv4DstAddr.toString(); |
| 1598 | break; |
| 1599 | case ACTION_SET_NW_TOS: |
| 1600 | ret += " action=" + actionSetIpToS.toString(); |
| 1601 | break; |
| 1602 | case ACTION_SET_TP_SRC: |
| 1603 | ret += " action=" + actionSetTcpUdpSrcPort.toString(); |
| 1604 | break; |
| 1605 | case ACTION_SET_TP_DST: |
| 1606 | ret += " action=" + actionSetTcpUdpDstPort.toString(); |
| 1607 | break; |
| 1608 | case ACTION_ENQUEUE: |
| 1609 | ret += " action=" + actionEnqueue.toString(); |
| 1610 | break; |
| 1611 | case ACTION_VENDOR: |
| 1612 | ret += " action=VENDOR"; |
| 1613 | break; |
Ray Milkey | 0b122ed | 2014-04-14 10:06:03 -0700 | [diff] [blame] | 1614 | default: |
| 1615 | ret += " action=unknown"; |
| 1616 | break; |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1617 | } |
| 1618 | ret += "]"; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1619 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1620 | return ret; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1621 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 1622 | |
| 1623 | /** |
| 1624 | * Convert a string to an action. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1625 | * <p/> |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 1626 | * The string has the following form: |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1627 | * [type=XXX action=XXX] |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 1628 | * |
| 1629 | * @param actionStr the action as a string. |
| 1630 | */ |
| 1631 | public void fromString(String actionStr) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1632 | String[] parts = actionStr.split("type="); |
| 1633 | String decode = null; |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 1634 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1635 | // Extract the string after the "type=" |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1636 | if (parts.length > 1) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1637 | decode = parts[1]; |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1638 | } |
| 1639 | if (decode == null) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1640 | throw new IllegalArgumentException("Invalid action string"); |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1641 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 1642 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1643 | // Remove the trailing ']' |
| 1644 | if ((decode.length() > 0) && (decode.charAt(decode.length() - 1) == ']')) { |
| 1645 | decode = decode.substring(0, decode.length() - 1); |
| 1646 | } else { |
| 1647 | throw new IllegalArgumentException("Invalid action string"); |
| 1648 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 1649 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1650 | // Extract the type value and the action value |
| 1651 | parts = decode.split(" action="); |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 1652 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1653 | // Decode the "type=XXX" payload |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1654 | if (parts.length > 0) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1655 | decode = parts[0]; |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1656 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1657 | if (decode != null) { |
| 1658 | try { |
| 1659 | actionType = Enum.valueOf(ActionValues.class, decode); |
| 1660 | } catch (IllegalArgumentException e) { |
| 1661 | throw new IllegalArgumentException("Invalid action string"); |
| 1662 | } |
| 1663 | } else { |
| 1664 | throw new IllegalArgumentException("Invalid action string"); |
| 1665 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 1666 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1667 | // Decode the "action=XXX" payload |
| 1668 | decode = null; |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1669 | if (parts.length > 1) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1670 | decode = parts[1]; |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1671 | } |
| 1672 | if (decode == null) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1673 | throw new IllegalArgumentException("Invalid action string"); |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 1674 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1675 | // |
| 1676 | try { |
| 1677 | switch (actionType) { |
| 1678 | case ACTION_OUTPUT: |
| 1679 | actionOutput = new ActionOutput(decode); |
| 1680 | break; |
| 1681 | case ACTION_SET_VLAN_VID: |
| 1682 | actionSetVlanId = new ActionSetVlanId(decode); |
| 1683 | break; |
| 1684 | case ACTION_SET_VLAN_PCP: |
| 1685 | actionSetVlanPriority = new ActionSetVlanPriority(decode); |
| 1686 | break; |
| 1687 | case ACTION_STRIP_VLAN: |
| 1688 | actionStripVlan = new ActionStripVlan(decode); |
| 1689 | break; |
| 1690 | case ACTION_SET_DL_SRC: |
| 1691 | actionSetEthernetSrcAddr = new ActionSetEthernetAddr(decode); |
| 1692 | break; |
| 1693 | case ACTION_SET_DL_DST: |
| 1694 | actionSetEthernetDstAddr = new ActionSetEthernetAddr(decode); |
| 1695 | break; |
| 1696 | case ACTION_SET_NW_SRC: |
| 1697 | actionSetIPv4SrcAddr = new ActionSetIPv4Addr(decode); |
| 1698 | break; |
| 1699 | case ACTION_SET_NW_DST: |
| 1700 | actionSetIPv4DstAddr = new ActionSetIPv4Addr(decode); |
| 1701 | break; |
| 1702 | case ACTION_SET_NW_TOS: |
| 1703 | actionSetIpToS = new ActionSetIpToS(decode); |
| 1704 | break; |
| 1705 | case ACTION_SET_TP_SRC: |
| 1706 | actionSetTcpUdpSrcPort = new ActionSetTcpUdpPort(decode); |
| 1707 | break; |
| 1708 | case ACTION_SET_TP_DST: |
| 1709 | actionSetTcpUdpDstPort = new ActionSetTcpUdpPort(decode); |
| 1710 | break; |
| 1711 | case ACTION_ENQUEUE: |
| 1712 | actionEnqueue = new ActionEnqueue(decode); |
| 1713 | break; |
| 1714 | case ACTION_VENDOR: |
| 1715 | // TODO: Handle it as appropriate |
| 1716 | break; |
Ray Milkey | 0b122ed | 2014-04-14 10:06:03 -0700 | [diff] [blame] | 1717 | default: |
| 1718 | throw new IllegalArgumentException("Invalid action string"); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1719 | } |
| 1720 | } catch (IllegalArgumentException e) { |
Ray Milkey | 0b122ed | 2014-04-14 10:06:03 -0700 | [diff] [blame] | 1721 | throw new IllegalArgumentException("Invalid action type", e); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 1722 | } |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 1723 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1724 | } |