HIGUCHI Yuta | 356086e | 2013-06-12 15:21:19 -0700 | [diff] [blame] | 1 | package net.onrc.onos.ofcontroller.util; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 2 | |
Pavlin Radoslavov | 27831be | 2013-10-28 23:40:29 -0700 | [diff] [blame] | 3 | import java.util.ArrayList; |
| 4 | |
HIGUCHI Yuta | 356086e | 2013-06-12 15:21:19 -0700 | [diff] [blame] | 5 | import net.floodlightcontroller.util.MACAddress; |
HIGUCHI Yuta | 2051490 | 2013-06-12 11:24:16 -0700 | [diff] [blame] | 6 | import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowEntry; |
| 7 | import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowPath; |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 8 | |
Pavlin Radoslavov | 892dd18 | 2013-12-05 23:33:15 -0800 | [diff] [blame] | 9 | import org.codehaus.jackson.annotate.JsonIgnore; |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 10 | import org.codehaus.jackson.annotate.JsonProperty; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 11 | |
| 12 | /** |
| 13 | * The class representing the Flow Path. |
| 14 | */ |
Umesh Krishnaswamy | 57a32a9 | 2013-03-21 14:21:15 -0700 | [diff] [blame] | 15 | public class FlowPath implements Comparable<FlowPath> { |
Pavlin Radoslavov | afbf103 | 2014-02-04 10:37:52 -0800 | [diff] [blame] | 16 | public static final int PRIORITY_DEFAULT = 32768; // Default Flow Priority |
| 17 | |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 18 | private FlowId flowId; // The Flow ID |
| 19 | private CallerId installerId; // The Caller ID of the path installer |
Pavlin Radoslavov | d28cf7c | 2013-10-26 11:27:43 -0700 | [diff] [blame] | 20 | private FlowPathType flowPathType; // The Flow Path type |
Pavlin Radoslavov | 7d4a40e | 2013-10-27 23:39:40 -0700 | [diff] [blame] | 21 | private FlowPathUserState flowPathUserState; // The Flow Path User state |
Pavlin Radoslavov | 204b286 | 2013-07-12 14:15:36 -0700 | [diff] [blame] | 22 | private FlowPathFlags flowPathFlags; // The Flow Path flags |
Pavlin Radoslavov | 5139c0b | 2013-12-09 18:04:53 -0800 | [diff] [blame] | 23 | private int idleTimeout; // The Flow idle timeout |
| 24 | private int hardTimeout; // The Flow hard timeout |
Pavlin Radoslavov | afbf103 | 2014-02-04 10:37:52 -0800 | [diff] [blame] | 25 | private int priority; // The Flow priority |
Pavlin Radoslavov | 5139c0b | 2013-12-09 18:04:53 -0800 | [diff] [blame] | 26 | private DataPath dataPath; // The data path |
Pavlin Radoslavov | 67b3ef3 | 2013-04-03 02:44:48 -0700 | [diff] [blame] | 27 | private FlowEntryMatch flowEntryMatch; // Common Flow Entry Match for all |
| 28 | // Flow Entries |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 29 | private FlowEntryActions flowEntryActions; // The Flow Entry Actions for |
| 30 | // the first Flow Entry |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 31 | |
| 32 | /** |
| 33 | * Default constructor. |
| 34 | */ |
| 35 | public FlowPath() { |
Pavlin Radoslavov | d28cf7c | 2013-10-26 11:27:43 -0700 | [diff] [blame] | 36 | flowPathType = FlowPathType.FP_TYPE_UNKNOWN; |
Pavlin Radoslavov | 7d4a40e | 2013-10-27 23:39:40 -0700 | [diff] [blame] | 37 | flowPathUserState = FlowPathUserState.FP_USER_UNKNOWN; |
Pavlin Radoslavov | 204b286 | 2013-07-12 14:15:36 -0700 | [diff] [blame] | 38 | flowPathFlags = new FlowPathFlags(); |
Pavlin Radoslavov | afbf103 | 2014-02-04 10:37:52 -0800 | [diff] [blame] | 39 | priority = FlowPath.PRIORITY_DEFAULT; |
Pavlin Radoslavov | b6f5354 | 2013-03-01 16:02:14 -0800 | [diff] [blame] | 40 | dataPath = new DataPath(); |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 41 | flowEntryActions = new FlowEntryActions(); |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 42 | } |
Pavlin Radoslavov | 67b3ef3 | 2013-04-03 02:44:48 -0700 | [diff] [blame] | 43 | |
Pankaj Berde | 6a97eb8 | 2013-03-28 12:12:43 -0700 | [diff] [blame] | 44 | /** |
| 45 | * Constructor to instantiate from object in Network Map |
| 46 | */ |
| 47 | public FlowPath(IFlowPath flowObj) { |
| 48 | dataPath = new DataPath(); |
| 49 | this.setFlowId(new FlowId(flowObj.getFlowId())); |
| 50 | this.setInstallerId(new CallerId(flowObj.getInstallerId())); |
Pavlin Radoslavov | d28cf7c | 2013-10-26 11:27:43 -0700 | [diff] [blame] | 51 | this.setFlowPathType(FlowPathType.valueOf(flowObj.getFlowPathType())); |
Pavlin Radoslavov | 7d4a40e | 2013-10-27 23:39:40 -0700 | [diff] [blame] | 52 | this.setFlowPathUserState(FlowPathUserState.valueOf(flowObj.getFlowPathUserState())); |
Pavlin Radoslavov | 204b286 | 2013-07-12 14:15:36 -0700 | [diff] [blame] | 53 | this.setFlowPathFlags(new FlowPathFlags(flowObj.getFlowPathFlags())); |
Pavlin Radoslavov | 5139c0b | 2013-12-09 18:04:53 -0800 | [diff] [blame] | 54 | this.setIdleTimeout(flowObj.getIdleTimeout()); |
| 55 | this.setHardTimeout(flowObj.getHardTimeout()); |
Pavlin Radoslavov | afbf103 | 2014-02-04 10:37:52 -0800 | [diff] [blame] | 56 | this.setPriority(flowObj.getPriority()); |
Pankaj Berde | 6a97eb8 | 2013-03-28 12:12:43 -0700 | [diff] [blame] | 57 | this.dataPath().srcPort().setDpid(new Dpid(flowObj.getSrcSwitch())); |
| 58 | this.dataPath().srcPort().setPort(new Port(flowObj.getSrcPort())); |
| 59 | this.dataPath().dstPort().setDpid(new Dpid(flowObj.getDstSwitch())); |
| 60 | this.dataPath().dstPort().setPort(new Port(flowObj.getDstPort())); |
Pavlin Radoslavov | 67b3ef3 | 2013-04-03 02:44:48 -0700 | [diff] [blame] | 61 | // |
| 62 | // Extract the match conditions that are common for all Flow Entries |
| 63 | // |
| 64 | { |
| 65 | FlowEntryMatch match = new FlowEntryMatch(); |
Pavlin Radoslavov | 67b3ef3 | 2013-04-03 02:44:48 -0700 | [diff] [blame] | 66 | String matchSrcMac = flowObj.getMatchSrcMac(); |
| 67 | if (matchSrcMac != null) |
| 68 | match.enableSrcMac(MACAddress.valueOf(matchSrcMac)); |
| 69 | String matchDstMac = flowObj.getMatchDstMac(); |
| 70 | if (matchDstMac != null) |
| 71 | match.enableDstMac(MACAddress.valueOf(matchDstMac)); |
Pavlin Radoslavov | ad3a1e6 | 2013-07-09 13:30:16 -0700 | [diff] [blame] | 72 | Short matchEthernetFrameType = flowObj.getMatchEthernetFrameType(); |
| 73 | if (matchEthernetFrameType != null) |
| 74 | match.enableEthernetFrameType(matchEthernetFrameType); |
| 75 | Short matchVlanId = flowObj.getMatchVlanId(); |
| 76 | if (matchVlanId != null) |
| 77 | match.enableVlanId(matchVlanId); |
| 78 | Byte matchVlanPriority = flowObj.getMatchVlanPriority(); |
| 79 | if (matchVlanPriority != null) |
| 80 | match.enableVlanPriority(matchVlanPriority); |
| 81 | String matchSrcIPv4Net = flowObj.getMatchSrcIPv4Net(); |
| 82 | if (matchSrcIPv4Net != null) |
| 83 | match.enableSrcIPv4Net(new IPv4Net(matchSrcIPv4Net)); |
| 84 | String matchDstIPv4Net = flowObj.getMatchDstIPv4Net(); |
| 85 | if (matchDstIPv4Net != null) |
| 86 | match.enableDstIPv4Net(new IPv4Net(matchDstIPv4Net)); |
| 87 | Byte matchIpProto = flowObj.getMatchIpProto(); |
| 88 | if (matchIpProto != null) |
| 89 | match.enableIpProto(matchIpProto); |
| 90 | Byte matchIpToS = flowObj.getMatchIpToS(); |
| 91 | if (matchIpToS != null) |
| 92 | match.enableIpToS(matchIpToS); |
| 93 | Short matchSrcTcpUdpPort = flowObj.getMatchSrcTcpUdpPort(); |
| 94 | if (matchSrcTcpUdpPort != null) |
| 95 | match.enableSrcTcpUdpPort(matchSrcTcpUdpPort); |
| 96 | Short matchDstTcpUdpPort = flowObj.getMatchDstTcpUdpPort(); |
| 97 | if (matchDstTcpUdpPort != null) |
| 98 | match.enableDstTcpUdpPort(matchDstTcpUdpPort); |
| 99 | |
Pavlin Radoslavov | 67b3ef3 | 2013-04-03 02:44:48 -0700 | [diff] [blame] | 100 | this.setFlowEntryMatch(match); |
| 101 | } |
Pankaj Berde | 6a97eb8 | 2013-03-28 12:12:43 -0700 | [diff] [blame] | 102 | |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 103 | // |
| 104 | // Extract the actions for the first Flow Entry |
| 105 | // |
| 106 | { |
| 107 | FlowEntryActions actions = new FlowEntryActions(); |
| 108 | |
| 109 | String actionsStr = flowObj.getActions(); |
| 110 | if (actions != null) |
| 111 | actions = new FlowEntryActions(actionsStr); |
| 112 | |
| 113 | this.setFlowEntryActions(actions); |
| 114 | } |
| 115 | |
Pankaj Berde | 6a97eb8 | 2013-03-28 12:12:43 -0700 | [diff] [blame] | 116 | // |
| 117 | // Extract all Flow Entries |
| 118 | // |
| 119 | Iterable<IFlowEntry> flowEntries = flowObj.getFlowEntries(); |
| 120 | for (IFlowEntry flowEntryObj : flowEntries) { |
| 121 | FlowEntry flowEntry = new FlowEntry(); |
| 122 | flowEntry.setFlowEntryId(new FlowEntryId(flowEntryObj.getFlowEntryId())); |
| 123 | flowEntry.setDpid(new Dpid(flowEntryObj.getSwitchDpid())); |
| 124 | |
| 125 | // |
| 126 | // Extract the match conditions |
| 127 | // |
| 128 | FlowEntryMatch match = new FlowEntryMatch(); |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 129 | // |
Pankaj Berde | 6a97eb8 | 2013-03-28 12:12:43 -0700 | [diff] [blame] | 130 | Short matchInPort = flowEntryObj.getMatchInPort(); |
| 131 | if (matchInPort != null) |
| 132 | match.enableInPort(new Port(matchInPort)); |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 133 | // |
Pankaj Berde | 6a97eb8 | 2013-03-28 12:12:43 -0700 | [diff] [blame] | 134 | String matchSrcMac = flowEntryObj.getMatchSrcMac(); |
| 135 | if (matchSrcMac != null) |
| 136 | match.enableSrcMac(MACAddress.valueOf(matchSrcMac)); |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 137 | // |
Pankaj Berde | 6a97eb8 | 2013-03-28 12:12:43 -0700 | [diff] [blame] | 138 | String matchDstMac = flowEntryObj.getMatchDstMac(); |
| 139 | if (matchDstMac != null) |
| 140 | match.enableDstMac(MACAddress.valueOf(matchDstMac)); |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 141 | // |
Pavlin Radoslavov | ad3a1e6 | 2013-07-09 13:30:16 -0700 | [diff] [blame] | 142 | Short matchEthernetFrameType = flowEntryObj.getMatchEthernetFrameType(); |
| 143 | if (matchEthernetFrameType != null) |
| 144 | match.enableEthernetFrameType(matchEthernetFrameType); |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 145 | // |
Pavlin Radoslavov | ad3a1e6 | 2013-07-09 13:30:16 -0700 | [diff] [blame] | 146 | Short matchVlanId = flowEntryObj.getMatchVlanId(); |
| 147 | if (matchVlanId != null) |
| 148 | match.enableVlanId(matchVlanId); |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 149 | // |
Pavlin Radoslavov | ad3a1e6 | 2013-07-09 13:30:16 -0700 | [diff] [blame] | 150 | Byte matchVlanPriority = flowEntryObj.getMatchVlanPriority(); |
| 151 | if (matchVlanPriority != null) |
| 152 | match.enableVlanPriority(matchVlanPriority); |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 153 | // |
Pavlin Radoslavov | ad3a1e6 | 2013-07-09 13:30:16 -0700 | [diff] [blame] | 154 | String matchSrcIPv4Net = flowEntryObj.getMatchSrcIPv4Net(); |
| 155 | if (matchSrcIPv4Net != null) |
| 156 | match.enableSrcIPv4Net(new IPv4Net(matchSrcIPv4Net)); |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 157 | // |
Pavlin Radoslavov | ad3a1e6 | 2013-07-09 13:30:16 -0700 | [diff] [blame] | 158 | String matchDstIPv4Net = flowEntryObj.getMatchDstIPv4Net(); |
| 159 | if (matchDstIPv4Net != null) |
| 160 | match.enableDstIPv4Net(new IPv4Net(matchDstIPv4Net)); |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 161 | // |
Pavlin Radoslavov | ad3a1e6 | 2013-07-09 13:30:16 -0700 | [diff] [blame] | 162 | Byte matchIpProto = flowEntryObj.getMatchIpProto(); |
| 163 | if (matchIpProto != null) |
| 164 | match.enableIpProto(matchIpProto); |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 165 | // |
Pavlin Radoslavov | ad3a1e6 | 2013-07-09 13:30:16 -0700 | [diff] [blame] | 166 | Byte matchIpToS = flowEntryObj.getMatchIpToS(); |
| 167 | if (matchIpToS != null) |
| 168 | match.enableIpToS(matchIpToS); |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 169 | // |
Pavlin Radoslavov | ad3a1e6 | 2013-07-09 13:30:16 -0700 | [diff] [blame] | 170 | Short matchSrcTcpUdpPort = flowEntryObj.getMatchSrcTcpUdpPort(); |
| 171 | if (matchSrcTcpUdpPort != null) |
| 172 | match.enableSrcTcpUdpPort(matchSrcTcpUdpPort); |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 173 | // |
Pavlin Radoslavov | ad3a1e6 | 2013-07-09 13:30:16 -0700 | [diff] [blame] | 174 | Short matchDstTcpUdpPort = flowEntryObj.getMatchDstTcpUdpPort(); |
| 175 | if (matchDstTcpUdpPort != null) |
| 176 | match.enableDstTcpUdpPort(matchDstTcpUdpPort); |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 177 | // |
Pankaj Berde | 6a97eb8 | 2013-03-28 12:12:43 -0700 | [diff] [blame] | 178 | flowEntry.setFlowEntryMatch(match); |
| 179 | |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 180 | // |
| 181 | // Extract the actions |
| 182 | // |
| 183 | { |
| 184 | FlowEntryActions actions = new FlowEntryActions(); |
| 185 | |
HIGUCHI Yuta | 6fa3951 | 2013-08-04 06:00:47 +0900 | [diff] [blame] | 186 | String actionsStr = flowEntryObj.getActions(); |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 187 | if (actions != null) |
| 188 | actions = new FlowEntryActions(actionsStr); |
| 189 | |
| 190 | flowEntry.setFlowEntryActions(actions); |
| 191 | } |
Pankaj Berde | 6a97eb8 | 2013-03-28 12:12:43 -0700 | [diff] [blame] | 192 | |
| 193 | String userState = flowEntryObj.getUserState(); |
| 194 | flowEntry.setFlowEntryUserState(FlowEntryUserState.valueOf(userState)); |
| 195 | String switchState = flowEntryObj.getSwitchState(); |
| 196 | flowEntry.setFlowEntrySwitchState(FlowEntrySwitchState.valueOf(switchState)); |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 197 | // |
| 198 | // TODO: Take care of the FlowEntryErrorState. |
| 199 | // |
Pankaj Berde | 6a97eb8 | 2013-03-28 12:12:43 -0700 | [diff] [blame] | 200 | this.dataPath().flowEntries().add(flowEntry); |
| 201 | } |
| 202 | } |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 203 | |
| 204 | /** |
| 205 | * Get the flow path Flow ID. |
| 206 | * |
| 207 | * @return the flow path Flow ID. |
| 208 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 209 | @JsonProperty("flowId") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 210 | public FlowId flowId() { return flowId; } |
| 211 | |
| 212 | /** |
| 213 | * Set the flow path Flow ID. |
| 214 | * |
| 215 | * @param flowId the flow path Flow ID to set. |
| 216 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 217 | @JsonProperty("flowId") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 218 | public void setFlowId(FlowId flowId) { |
| 219 | this.flowId = flowId; |
| 220 | } |
| 221 | |
| 222 | /** |
Pavlin Radoslavov | 892dd18 | 2013-12-05 23:33:15 -0800 | [diff] [blame] | 223 | * Test whether the Flow ID is valid. |
| 224 | * |
| 225 | * @return true if the Flow ID is valid, otherwise false. |
| 226 | */ |
| 227 | @JsonIgnore |
| 228 | public boolean isValidFlowId() { |
| 229 | if (this.flowId == null) |
| 230 | return false; |
| 231 | return (this.flowId.isValid()); |
| 232 | } |
| 233 | |
| 234 | /** |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 235 | * Get the Caller ID of the flow path installer. |
| 236 | * |
| 237 | * @return the Caller ID of the flow path installer. |
| 238 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 239 | @JsonProperty("installerId") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 240 | public CallerId installerId() { return installerId; } |
| 241 | |
| 242 | /** |
| 243 | * Set the Caller ID of the flow path installer. |
| 244 | * |
| 245 | * @param installerId the Caller ID of the flow path installer. |
| 246 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 247 | @JsonProperty("installerId") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 248 | public void setInstallerId(CallerId installerId) { |
| 249 | this.installerId = installerId; |
| 250 | } |
| 251 | |
| 252 | /** |
Pavlin Radoslavov | d28cf7c | 2013-10-26 11:27:43 -0700 | [diff] [blame] | 253 | * Get the flow path type. |
| 254 | * |
| 255 | * @return the flow path type. |
| 256 | */ |
| 257 | @JsonProperty("flowPathType") |
| 258 | public FlowPathType flowPathType() { return flowPathType; } |
| 259 | |
| 260 | /** |
| 261 | * Set the flow path type. |
| 262 | * |
| 263 | * @param flowPathType the flow path type to set. |
| 264 | */ |
| 265 | @JsonProperty("flowPathType") |
| 266 | public void setFlowPathType(FlowPathType flowPathType) { |
| 267 | this.flowPathType = flowPathType; |
| 268 | } |
| 269 | |
| 270 | /** |
Pavlin Radoslavov | 7d4a40e | 2013-10-27 23:39:40 -0700 | [diff] [blame] | 271 | * Get the flow path user state. |
| 272 | * |
| 273 | * @return the flow path user state. |
| 274 | */ |
| 275 | @JsonProperty("flowPathUserState") |
| 276 | public FlowPathUserState flowPathUserState() { return flowPathUserState; } |
| 277 | |
| 278 | /** |
| 279 | * Set the flow path user state. |
| 280 | * |
| 281 | * @param flowPathUserState the flow path user state to set. |
| 282 | */ |
| 283 | @JsonProperty("flowPathUserState") |
| 284 | public void setFlowPathUserState(FlowPathUserState flowPathUserState) { |
| 285 | this.flowPathUserState = flowPathUserState; |
| 286 | } |
| 287 | |
| 288 | /** |
Pavlin Radoslavov | 204b286 | 2013-07-12 14:15:36 -0700 | [diff] [blame] | 289 | * Get the flow path flags. |
| 290 | * |
| 291 | * @return the flow path flags. |
| 292 | */ |
| 293 | @JsonProperty("flowPathFlags") |
| 294 | public FlowPathFlags flowPathFlags() { return flowPathFlags; } |
| 295 | |
| 296 | /** |
| 297 | * Set the flow path flags. |
| 298 | * |
| 299 | * @param flowPathFlags the flow path flags to set. |
| 300 | */ |
| 301 | @JsonProperty("flowPathFlags") |
| 302 | public void setFlowPathFlags(FlowPathFlags flowPathFlags) { |
| 303 | this.flowPathFlags = flowPathFlags; |
| 304 | } |
| 305 | |
| 306 | /** |
Pavlin Radoslavov | 5139c0b | 2013-12-09 18:04:53 -0800 | [diff] [blame] | 307 | * Get the flow idle timeout in seconds. |
| 308 | * |
| 309 | * It should be an unsigned integer in the interval [0, 65535]. |
| 310 | * If zero, the timeout is not set. |
| 311 | * |
| 312 | * @return the flow idle timeout. |
| 313 | */ |
| 314 | @JsonProperty("idleTimeout") |
| 315 | public int idleTimeout() { return idleTimeout; } |
| 316 | |
| 317 | /** |
| 318 | * Set the flow idle timeout in seconds. |
| 319 | * |
| 320 | * It should be an unsigned integer in the interval [0, 65535]. |
| 321 | * If zero, the timeout is not set. |
| 322 | * |
| 323 | * @param idleTimeout the flow idle timeout to set. |
| 324 | */ |
| 325 | @JsonProperty("idleTimeout") |
| 326 | public void setIdleTimeout(int idleTimeout) { |
| 327 | this.idleTimeout = 0xffff & idleTimeout; |
| 328 | } |
| 329 | |
| 330 | /** |
| 331 | * Get the flow hard timeout in seconds. |
| 332 | * |
| 333 | * It should be an unsigned integer in the interval [0, 65535]. |
| 334 | * If zero, the timeout is not set. |
| 335 | * |
| 336 | * @return the flow hard timeout. |
| 337 | */ |
| 338 | @JsonProperty("hardTimeout") |
| 339 | public int hardTimeout() { return hardTimeout; } |
| 340 | |
| 341 | /** |
| 342 | * Set the flow hard timeout. |
| 343 | * |
| 344 | * It should be an unsigned integer in the interval [0, 65535]. |
| 345 | * If zero, the timeout is not set. |
| 346 | * |
| 347 | * @param hardTimeout the flow hard timeout to set. |
| 348 | */ |
| 349 | @JsonProperty("hardTimeout") |
| 350 | public void setHardTimeout(int hardTimeout) { |
| 351 | this.hardTimeout = 0xffff & hardTimeout; |
| 352 | } |
| 353 | |
| 354 | /** |
Pavlin Radoslavov | afbf103 | 2014-02-04 10:37:52 -0800 | [diff] [blame] | 355 | * Get the flow priority. |
| 356 | * |
| 357 | * It should be an unsigned integer in the interval [0, 65535]. |
| 358 | * |
| 359 | * @return the flow priority. |
| 360 | */ |
| 361 | @JsonProperty("priority") |
| 362 | public int priority() { return priority; } |
| 363 | |
| 364 | /** |
| 365 | * Set the flow priority. |
| 366 | * |
| 367 | * It should be an unsigned integer in the interval [0, 65535]. |
| 368 | * |
| 369 | * @param priority the flow priority to set. |
| 370 | */ |
| 371 | @JsonProperty("priority") |
| 372 | public void setPriority(int priority) { |
| 373 | this.priority = 0xffff & priority; |
| 374 | } |
| 375 | |
| 376 | /** |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 377 | * Get the flow path's data path. |
| 378 | * |
| 379 | * @return the flow path's data path. |
| 380 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 381 | @JsonProperty("dataPath") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 382 | public DataPath dataPath() { return dataPath; } |
| 383 | |
| 384 | /** |
| 385 | * Set the flow path's data path. |
| 386 | * |
| 387 | * @param dataPath the flow path's data path to set. |
| 388 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 389 | @JsonProperty("dataPath") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 390 | public void setDataPath(DataPath dataPath) { |
| 391 | this.dataPath = dataPath; |
| 392 | } |
| 393 | |
| 394 | /** |
Pavlin Radoslavov | 27831be | 2013-10-28 23:40:29 -0700 | [diff] [blame] | 395 | * Get the data path flow entries. |
| 396 | * |
| 397 | * @return the data path flow entries. |
| 398 | */ |
| 399 | public ArrayList<FlowEntry> flowEntries() { |
| 400 | return this.dataPath.flowEntries(); |
| 401 | } |
| 402 | |
| 403 | /** |
Pavlin Radoslavov | 67b3ef3 | 2013-04-03 02:44:48 -0700 | [diff] [blame] | 404 | * Get the flow path's match conditions common for all Flow Entries. |
| 405 | * |
| 406 | * @return the flow path's match conditions common for all Flow Entries. |
| 407 | */ |
| 408 | @JsonProperty("flowEntryMatch") |
| 409 | public FlowEntryMatch flowEntryMatch() { return flowEntryMatch; } |
| 410 | |
| 411 | /** |
| 412 | * Set the flow path's match conditions common for all Flow Entries. |
| 413 | * |
| 414 | * @param flowEntryMatch the flow path's match conditions common for all |
| 415 | * Flow Entries. |
| 416 | */ |
| 417 | @JsonProperty("flowEntryMatch") |
| 418 | public void setFlowEntryMatch(FlowEntryMatch flowEntryMatch) { |
| 419 | this.flowEntryMatch = flowEntryMatch; |
| 420 | } |
| 421 | |
| 422 | /** |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 423 | * Get the flow path's flow entry actions for the first Flow Entry. |
| 424 | * |
| 425 | * @return the flow path's flow entry actions for the first Flow Entry. |
| 426 | */ |
| 427 | @JsonProperty("flowEntryActions") |
| 428 | public FlowEntryActions flowEntryActions() { |
| 429 | return flowEntryActions; |
| 430 | } |
| 431 | |
| 432 | /** |
| 433 | * Set the flow path's flow entry actions for the first Flow Entry. |
| 434 | * |
| 435 | * @param flowEntryActions the flow path's flow entry actions for the first |
| 436 | * Flow Entry. |
| 437 | */ |
| 438 | @JsonProperty("flowEntryActions") |
| 439 | public void setFlowEntryActions(FlowEntryActions flowEntryActions) { |
| 440 | this.flowEntryActions = flowEntryActions; |
| 441 | } |
| 442 | |
| 443 | /** |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 444 | * Convert the flow path to a string. |
| 445 | * |
Pavlin Radoslavov | a10a9a8 | 2013-02-22 11:47:54 -0800 | [diff] [blame] | 446 | * The string has the following form: |
Pavlin Radoslavov | 7d4a40e | 2013-10-27 23:39:40 -0700 | [diff] [blame] | 447 | * [flowId=XXX installerId=XXX flowPathType = XXX flowPathUserState = XXX |
Pavlin Radoslavov | afbf103 | 2014-02-04 10:37:52 -0800 | [diff] [blame] | 448 | * flowPathFlags=XXX idleTimeout=XXX hardTimeout=XXX priority=XXX |
| 449 | * dataPath=XXX flowEntryMatch=XXX flowEntryActions=XXX] |
Pavlin Radoslavov | a10a9a8 | 2013-02-22 11:47:54 -0800 | [diff] [blame] | 450 | * |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 451 | * @return the flow path as a string. |
| 452 | */ |
| 453 | @Override |
| 454 | public String toString() { |
Pavlin Radoslavov | a10a9a8 | 2013-02-22 11:47:54 -0800 | [diff] [blame] | 455 | String ret = "[flowId=" + this.flowId.toString(); |
| 456 | ret += " installerId=" + this.installerId.toString(); |
Pavlin Radoslavov | d28cf7c | 2013-10-26 11:27:43 -0700 | [diff] [blame] | 457 | ret += " flowPathType=" + this.flowPathType; |
Pavlin Radoslavov | 7d4a40e | 2013-10-27 23:39:40 -0700 | [diff] [blame] | 458 | ret += " flowPathUserState=" + this.flowPathUserState; |
Pavlin Radoslavov | 204b286 | 2013-07-12 14:15:36 -0700 | [diff] [blame] | 459 | ret += " flowPathFlags=" + this.flowPathFlags.toString(); |
Pavlin Radoslavov | 5139c0b | 2013-12-09 18:04:53 -0800 | [diff] [blame] | 460 | ret += " idleTimeout=" + this.idleTimeout; |
| 461 | ret += " hardTimeout=" + this.hardTimeout; |
Pavlin Radoslavov | afbf103 | 2014-02-04 10:37:52 -0800 | [diff] [blame] | 462 | ret += " priority=" + this.priority; |
Pavlin Radoslavov | 67b3ef3 | 2013-04-03 02:44:48 -0700 | [diff] [blame] | 463 | if (dataPath != null) |
| 464 | ret += " dataPath=" + this.dataPath.toString(); |
| 465 | if (flowEntryMatch != null) |
| 466 | ret += " flowEntryMatch=" + this.flowEntryMatch.toString(); |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 467 | if (flowEntryActions != null) |
| 468 | ret += " flowEntryActions=" + this.flowEntryActions.toString(); |
Pavlin Radoslavov | a10a9a8 | 2013-02-22 11:47:54 -0800 | [diff] [blame] | 469 | ret += "]"; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 470 | return ret; |
| 471 | } |
Umesh Krishnaswamy | 57a32a9 | 2013-03-21 14:21:15 -0700 | [diff] [blame] | 472 | |
| 473 | /** |
| 474 | * CompareTo method to order flowPath by Id |
| 475 | */ |
| 476 | @Override |
| 477 | public int compareTo(FlowPath f) { |
| 478 | return (int) (this.flowId.value() - f.flowId.value()); |
| 479 | } |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 480 | } |