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; |
| 7 | import net.floodlightcontroller.util.Port; |
| 8 | |
| 9 | /** |
| 10 | * The Flow Entry state as set by the user (via the ONOS API). |
| 11 | */ |
| 12 | enum FlowEntryUserState { |
| 13 | FE_USER_UNKNOWN, // Initialization value: state unknown |
| 14 | FE_USER_ADD, // Flow entry that is added |
| 15 | FE_USER_MODIFY, // Flow entry that is modified |
| 16 | FE_USER_DELETE // Flow entry that is deleted |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * The Flow Entry state as set by the controller. |
| 21 | */ |
| 22 | enum FlowEntrySwitchState { |
| 23 | FE_SWITCH_UNKNOWN, // Initialization value: state unknown |
| 24 | FE_SWITCH_NOT_UPDATED, // Switch not updated with this entry |
| 25 | FE_SWITCH_UPDATE_IN_PROGRESS, // Switch update in progress |
| 26 | FE_SWITCH_UPDATED, // Switch updated with this entry |
| 27 | FE_SWITCH_UPDATE_FAILED // Error updating the switch with this entry |
| 28 | } |
| 29 | |
| 30 | |
| 31 | /** |
| 32 | * The class representing the Flow Entry. |
| 33 | * |
| 34 | * NOTE: The specification is incomplete. E.g., the entry needs to |
| 35 | * support multiple in-ports and multiple out-ports. |
| 36 | */ |
| 37 | public class FlowEntry { |
| 38 | private FlowEntryId flowEntryId; // The Flow Entry ID |
| 39 | private FlowEntryMatch flowEntryMatch; // The Flow Entry Match |
| 40 | private FlowEntryActions flowEntryActions; // The Flow Entry Actions |
| 41 | private Dpid dpid; // The Switch DPID |
| 42 | private Port inPort; // The Switch incoming port |
| 43 | private Port outPort; // The Switch outgoing port |
| 44 | private FlowEntryUserState flowEntryUserState; // The Flow Entry User state |
| 45 | private FlowEntrySwitchState flowEntrySwitchState; // The Flow Entry Switch state |
| 46 | // The Flow Entry Error state (if FlowEntrySwitchState is FE_SWITCH_FAILED) |
| 47 | private FlowEntryErrorState flowEntryErrorState; |
| 48 | |
| 49 | /** |
| 50 | * Default constructor. |
| 51 | */ |
| 52 | public FlowEntry() { |
| 53 | flowEntryUserState = FlowEntryUserState.FE_USER_UNKNOWN; |
| 54 | flowEntrySwitchState = FlowEntrySwitchState.FE_SWITCH_UNKNOWN; |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Get the Flow Entry ID. |
| 59 | * |
| 60 | * @return the Flow Entry ID. |
| 61 | */ |
| 62 | public FlowEntryId flowEntryId() { return flowEntryId; } |
| 63 | |
| 64 | /** |
| 65 | * Set the Flow Entry ID. |
| 66 | * |
| 67 | * @param flowEntryId the Flow Entry ID to set. |
| 68 | */ |
| 69 | public void setFlowEntryId(FlowEntryId flowEntryId) { |
| 70 | this.flowEntryId = flowEntryId; |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Get the Flow Entry Match. |
| 75 | * |
| 76 | * @return the Flow Entry Match. |
| 77 | */ |
| 78 | public FlowEntryMatch flowEntryMatch() { return flowEntryMatch; } |
| 79 | |
| 80 | /** |
| 81 | * Set the Flow Entry Match. |
| 82 | * |
| 83 | * @param flowEntryMatch the Flow Entry Match to set. |
| 84 | */ |
| 85 | public void setFlowEntryMatch(FlowEntryMatch flowEntryMatch) { |
| 86 | this.flowEntryMatch = flowEntryMatch; |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Get the Flow Entry Actions. |
| 91 | * |
| 92 | * @return the Flow Entry Actions. |
| 93 | */ |
| 94 | public FlowEntryActions flowEntryActions() { return flowEntryActions; } |
| 95 | |
| 96 | /** |
| 97 | * Set the Flow Entry Actions. |
| 98 | * |
| 99 | * @param flowEntryActions the Flow Entry Actions to set. |
| 100 | */ |
| 101 | public void setFlowEntryActions(FlowEntryActions flowEntryActions) { |
| 102 | this.flowEntryActions = flowEntryActions; |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * Get the Switch DPID. |
| 107 | * |
| 108 | * @return the Switch DPID. |
| 109 | */ |
| 110 | public Dpid dpid() { return dpid; } |
| 111 | |
| 112 | /** |
| 113 | * Set the Switch DPID. |
| 114 | * |
| 115 | * @param dpid the Switch DPID to set. |
| 116 | */ |
| 117 | public void setDpid(Dpid dpid) { |
| 118 | this.dpid = dpid; |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * Get the Switch incoming port. |
| 123 | * |
| 124 | * @return the Switch incoming port. |
| 125 | */ |
| 126 | public Port inPort() { return inPort; } |
| 127 | |
| 128 | /** |
| 129 | * Set the Switch incoming port. |
| 130 | * |
| 131 | * @param inPort the Switch incoming port to set. |
| 132 | */ |
| 133 | public void setInPort(Port inPort) { |
| 134 | this.inPort = inPort; |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * Get the Switch outgoing port. |
| 139 | * |
| 140 | * @return the Switch outgoing port. |
| 141 | */ |
| 142 | public Port outPort() { return outPort; } |
| 143 | |
| 144 | /** |
| 145 | * Set the Switch outgoing port. |
| 146 | * |
| 147 | * @param outPort the Switch outgoing port to set. |
| 148 | */ |
| 149 | public void setOutPort(Port outPort) { |
| 150 | this.outPort = outPort; |
| 151 | } |
| 152 | |
| 153 | /** |
| 154 | * Get the Flow Entry User state. |
| 155 | * |
| 156 | * @return the Flow Entry User state. |
| 157 | */ |
| 158 | public FlowEntryUserState flowEntryUserState() { |
| 159 | return flowEntryUserState; |
| 160 | } |
| 161 | |
| 162 | /** |
| 163 | * Set the Flow Entry User state. |
| 164 | * |
| 165 | * @param flowEntryUserState the Flow Entry User state to set. |
| 166 | */ |
| 167 | public void setFlowEntryUserState(FlowEntryUserState flowEntryUserState) { |
| 168 | this.flowEntryUserState = flowEntryUserState; |
| 169 | } |
| 170 | |
| 171 | /** |
| 172 | * Get the Flow Entry Switch state. |
| 173 | * |
| 174 | * The Flow Entry Error state is used if FlowEntrySwitchState is |
| 175 | * FE_SWITCH_FAILED. |
| 176 | * |
| 177 | * @return the Flow Entry Switch state. |
| 178 | */ |
| 179 | public FlowEntrySwitchState flowEntrySwitchState() { |
| 180 | return flowEntrySwitchState; |
| 181 | } |
| 182 | |
| 183 | /** |
| 184 | * Set the Flow Entry Switch state. |
| 185 | * |
| 186 | * The Flow Entry Error state is used if FlowEntrySwitchState is |
| 187 | * FE_SWITCH_FAILED. |
| 188 | * |
| 189 | * @param flowEntrySwitchState the Flow Entry Switch state to set. |
| 190 | */ |
| 191 | public void setFlowEntrySwitchState(FlowEntrySwitchState flowEntrySwitchState) { |
| 192 | this.flowEntrySwitchState = flowEntrySwitchState; |
| 193 | } |
| 194 | |
| 195 | /** |
| 196 | * Get the Flow Entry Error state. |
| 197 | * |
| 198 | * @return the Flow Entry Error state. |
| 199 | */ |
| 200 | public FlowEntryErrorState flowEntryErrorState() { |
| 201 | return flowEntryErrorState; |
| 202 | } |
| 203 | |
| 204 | /** |
| 205 | * Set the Flow Entry Error state. |
| 206 | * |
| 207 | * @param flowEntryErrorState the Flow Entry Error state to set. |
| 208 | */ |
| 209 | public void setFlowEntryErrorState(FlowEntryErrorState flowEntryErrorState) { |
| 210 | this.flowEntryErrorState = flowEntryErrorState; |
| 211 | } |
| 212 | |
| 213 | /** |
| 214 | * Convert the flow entry to a string. |
| 215 | * |
| 216 | * @return the flow entry as a string. |
| 217 | */ |
| 218 | @Override |
| 219 | public String toString() { |
| 220 | String ret = ""; |
| 221 | // TODO: Implement it! |
| 222 | return ret; |
| 223 | } |
| 224 | } |