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