Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 1 | package net.floodlightcontroller.util; |
| 2 | |
| 3 | import net.floodlightcontroller.util.Dpid; |
| 4 | import net.floodlightcontroller.util.FlowEntryActions; |
| 5 | import net.floodlightcontroller.util.FlowEntryId; |
| 6 | import net.floodlightcontroller.util.FlowEntryMatch; |
Pavlin Radoslavov | b6f5354 | 2013-03-01 16:02:14 -0800 | [diff] [blame] | 7 | import net.floodlightcontroller.util.FlowEntrySwitchState; |
| 8 | import net.floodlightcontroller.util.FlowEntryUserState; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 9 | import net.floodlightcontroller.util.Port; |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 10 | |
| 11 | import org.codehaus.jackson.annotate.JsonProperty; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 12 | |
| 13 | /** |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 14 | * The class representing the Flow Entry. |
| 15 | * |
| 16 | * NOTE: The specification is incomplete. E.g., the entry needs to |
| 17 | * support multiple in-ports and multiple out-ports. |
| 18 | */ |
| 19 | public class FlowEntry { |
| 20 | private FlowEntryId flowEntryId; // The Flow Entry ID |
| 21 | private FlowEntryMatch flowEntryMatch; // The Flow Entry Match |
| 22 | private FlowEntryActions flowEntryActions; // The Flow Entry Actions |
| 23 | private Dpid dpid; // The Switch DPID |
| 24 | private Port inPort; // The Switch incoming port |
| 25 | private Port outPort; // The Switch outgoing port |
| 26 | private FlowEntryUserState flowEntryUserState; // The Flow Entry User state |
| 27 | private FlowEntrySwitchState flowEntrySwitchState; // The Flow Entry Switch state |
| 28 | // The Flow Entry Error state (if FlowEntrySwitchState is FE_SWITCH_FAILED) |
| 29 | private FlowEntryErrorState flowEntryErrorState; |
| 30 | |
| 31 | /** |
| 32 | * Default constructor. |
| 33 | */ |
| 34 | public FlowEntry() { |
| 35 | flowEntryUserState = FlowEntryUserState.FE_USER_UNKNOWN; |
| 36 | flowEntrySwitchState = FlowEntrySwitchState.FE_SWITCH_UNKNOWN; |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Get the Flow Entry ID. |
| 41 | * |
| 42 | * @return the Flow Entry ID. |
| 43 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 44 | @JsonProperty("flowEntryId") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 45 | public FlowEntryId flowEntryId() { return flowEntryId; } |
| 46 | |
| 47 | /** |
| 48 | * Set the Flow Entry ID. |
| 49 | * |
| 50 | * @param flowEntryId the Flow Entry ID to set. |
| 51 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 52 | @JsonProperty("flowEntryId") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 53 | public void setFlowEntryId(FlowEntryId flowEntryId) { |
| 54 | this.flowEntryId = flowEntryId; |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Get the Flow Entry Match. |
| 59 | * |
| 60 | * @return the Flow Entry Match. |
| 61 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 62 | @JsonProperty("flowEntryMatch") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 63 | public FlowEntryMatch flowEntryMatch() { return flowEntryMatch; } |
| 64 | |
| 65 | /** |
| 66 | * Set the Flow Entry Match. |
| 67 | * |
| 68 | * @param flowEntryMatch the Flow Entry Match to set. |
| 69 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 70 | @JsonProperty("flowEntryMatch") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 71 | public void setFlowEntryMatch(FlowEntryMatch flowEntryMatch) { |
| 72 | this.flowEntryMatch = flowEntryMatch; |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Get the Flow Entry Actions. |
| 77 | * |
| 78 | * @return the Flow Entry Actions. |
| 79 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 80 | @JsonProperty("flowEntryActions") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 81 | public FlowEntryActions flowEntryActions() { return flowEntryActions; } |
| 82 | |
| 83 | /** |
| 84 | * Set the Flow Entry Actions. |
| 85 | * |
| 86 | * @param flowEntryActions the Flow Entry Actions to set. |
| 87 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 88 | @JsonProperty("flowEntryActions") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 89 | public void setFlowEntryActions(FlowEntryActions flowEntryActions) { |
| 90 | this.flowEntryActions = flowEntryActions; |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * Get the Switch DPID. |
| 95 | * |
| 96 | * @return the Switch DPID. |
| 97 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 98 | @JsonProperty("dpid") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 99 | public Dpid dpid() { return dpid; } |
| 100 | |
| 101 | /** |
| 102 | * Set the Switch DPID. |
| 103 | * |
| 104 | * @param dpid the Switch DPID to set. |
| 105 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 106 | @JsonProperty("dpid") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 107 | public void setDpid(Dpid dpid) { |
| 108 | this.dpid = dpid; |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * Get the Switch incoming port. |
| 113 | * |
| 114 | * @return the Switch incoming port. |
| 115 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 116 | @JsonProperty("inPort") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 117 | public Port inPort() { return inPort; } |
| 118 | |
| 119 | /** |
| 120 | * Set the Switch incoming port. |
| 121 | * |
| 122 | * @param inPort the Switch incoming port to set. |
| 123 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 124 | @JsonProperty("inPort") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 125 | public void setInPort(Port inPort) { |
| 126 | this.inPort = inPort; |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * Get the Switch outgoing port. |
| 131 | * |
| 132 | * @return the Switch outgoing port. |
| 133 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 134 | @JsonProperty("outPort") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 135 | public Port outPort() { return outPort; } |
| 136 | |
| 137 | /** |
| 138 | * Set the Switch outgoing port. |
| 139 | * |
| 140 | * @param outPort the Switch outgoing port to set. |
| 141 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 142 | @JsonProperty("outPort") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 143 | public void setOutPort(Port outPort) { |
| 144 | this.outPort = outPort; |
| 145 | } |
| 146 | |
| 147 | /** |
| 148 | * Get the Flow Entry User state. |
| 149 | * |
| 150 | * @return the Flow Entry User state. |
| 151 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 152 | @JsonProperty("flowEntryUserState") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 153 | public FlowEntryUserState flowEntryUserState() { |
| 154 | return flowEntryUserState; |
| 155 | } |
| 156 | |
| 157 | /** |
| 158 | * Set the Flow Entry User state. |
| 159 | * |
| 160 | * @param flowEntryUserState the Flow Entry User state to set. |
| 161 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 162 | @JsonProperty("flowEntryUserState") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 163 | public void setFlowEntryUserState(FlowEntryUserState flowEntryUserState) { |
| 164 | this.flowEntryUserState = flowEntryUserState; |
| 165 | } |
| 166 | |
| 167 | /** |
| 168 | * Get the Flow Entry Switch state. |
| 169 | * |
| 170 | * The Flow Entry Error state is used if FlowEntrySwitchState is |
| 171 | * FE_SWITCH_FAILED. |
| 172 | * |
| 173 | * @return the Flow Entry Switch state. |
| 174 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 175 | @JsonProperty("flowEntrySwitchState") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 176 | public FlowEntrySwitchState flowEntrySwitchState() { |
| 177 | return flowEntrySwitchState; |
| 178 | } |
| 179 | |
| 180 | /** |
| 181 | * Set the Flow Entry Switch state. |
| 182 | * |
| 183 | * The Flow Entry Error state is used if FlowEntrySwitchState is |
| 184 | * FE_SWITCH_FAILED. |
| 185 | * |
| 186 | * @param flowEntrySwitchState the Flow Entry Switch state to set. |
| 187 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 188 | @JsonProperty("flowEntrySwitchState") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 189 | public void setFlowEntrySwitchState(FlowEntrySwitchState flowEntrySwitchState) { |
| 190 | this.flowEntrySwitchState = flowEntrySwitchState; |
| 191 | } |
| 192 | |
| 193 | /** |
| 194 | * Get the Flow Entry Error state. |
| 195 | * |
| 196 | * @return the Flow Entry Error state. |
| 197 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 198 | @JsonProperty("flowEntryErrorState") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 199 | public FlowEntryErrorState flowEntryErrorState() { |
| 200 | return flowEntryErrorState; |
| 201 | } |
| 202 | |
| 203 | /** |
| 204 | * Set the Flow Entry Error state. |
| 205 | * |
| 206 | * @param flowEntryErrorState the Flow Entry Error state to set. |
| 207 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 208 | @JsonProperty("flowEntryErrorState") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 209 | public void setFlowEntryErrorState(FlowEntryErrorState flowEntryErrorState) { |
| 210 | this.flowEntryErrorState = flowEntryErrorState; |
| 211 | } |
| 212 | |
| 213 | /** |
| 214 | * Convert the flow entry to a string. |
| 215 | * |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 216 | * The string has the following form: |
Pavlin Radoslavov | a10a9a8 | 2013-02-22 11:47:54 -0800 | [diff] [blame] | 217 | * [flowEntryId=XXX flowEntryMatch=XXX flowEntryActions=XXX dpid=XXX |
| 218 | * inPort=XXX outPort=XXX flowEntryUserState=XXX flowEntrySwitchState=XXX |
| 219 | * flowEntryErrorState=XXX] |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 220 | * @return the flow entry as a string. |
| 221 | */ |
| 222 | @Override |
| 223 | public String toString() { |
Pavlin Radoslavov | a10a9a8 | 2013-02-22 11:47:54 -0800 | [diff] [blame] | 224 | String ret = "[flowEntryId=" + this.flowEntryId.toString(); |
| 225 | ret += " flowEntryMatch=" + this.flowEntryMatch.toString(); |
| 226 | ret += " flowEntryActions=" + this.flowEntryActions.toString(); |
| 227 | ret += " dpid=" + this.dpid.toString(); |
| 228 | ret += " inPort=" + this.inPort.toString(); |
| 229 | ret += " outPort=" + this.outPort.toString(); |
| 230 | ret += " flowEntryUserState=" + this.flowEntryUserState; |
| 231 | ret += " flowEntrySwitchState=" + this.flowEntrySwitchState; |
| 232 | ret += " flowEntryErrorState=" + this.flowEntryErrorState.toString(); |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 233 | ret += "]"; |
| 234 | |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 235 | return ret; |
| 236 | } |
| 237 | } |