blob: dfb8f828b9e858b8b76573bac566d9962f7fc13e [file] [log] [blame]
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -08001package net.floodlightcontroller.util;
2
3import net.floodlightcontroller.util.Dpid;
4import net.floodlightcontroller.util.FlowEntryActions;
5import net.floodlightcontroller.util.FlowEntryId;
6import net.floodlightcontroller.util.FlowEntryMatch;
7import net.floodlightcontroller.util.Port;
Pavlin Radoslavovad008e02013-02-21 18:42:42 -08008
9import org.codehaus.jackson.annotate.JsonProperty;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080010
11/**
12 * The Flow Entry state as set by the user (via the ONOS API).
13 */
14enum FlowEntryUserState {
15 FE_USER_UNKNOWN, // Initialization value: state unknown
16 FE_USER_ADD, // Flow entry that is added
17 FE_USER_MODIFY, // Flow entry that is modified
18 FE_USER_DELETE // Flow entry that is deleted
19}
20
21/**
22 * The Flow Entry state as set by the controller.
23 */
24enum FlowEntrySwitchState {
25 FE_SWITCH_UNKNOWN, // Initialization value: state unknown
26 FE_SWITCH_NOT_UPDATED, // Switch not updated with this entry
27 FE_SWITCH_UPDATE_IN_PROGRESS, // Switch update in progress
28 FE_SWITCH_UPDATED, // Switch updated with this entry
29 FE_SWITCH_UPDATE_FAILED // Error updating the switch with this entry
30}
31
32
33/**
34 * The class representing the Flow Entry.
35 *
36 * NOTE: The specification is incomplete. E.g., the entry needs to
37 * support multiple in-ports and multiple out-ports.
38 */
39public class FlowEntry {
40 private FlowEntryId flowEntryId; // The Flow Entry ID
41 private FlowEntryMatch flowEntryMatch; // The Flow Entry Match
42 private FlowEntryActions flowEntryActions; // The Flow Entry Actions
43 private Dpid dpid; // The Switch DPID
44 private Port inPort; // The Switch incoming port
45 private Port outPort; // The Switch outgoing port
46 private FlowEntryUserState flowEntryUserState; // The Flow Entry User state
47 private FlowEntrySwitchState flowEntrySwitchState; // The Flow Entry Switch state
48 // The Flow Entry Error state (if FlowEntrySwitchState is FE_SWITCH_FAILED)
49 private FlowEntryErrorState flowEntryErrorState;
50
51 /**
52 * Default constructor.
53 */
54 public FlowEntry() {
55 flowEntryUserState = FlowEntryUserState.FE_USER_UNKNOWN;
56 flowEntrySwitchState = FlowEntrySwitchState.FE_SWITCH_UNKNOWN;
57 }
58
59 /**
60 * Get the Flow Entry ID.
61 *
62 * @return the Flow Entry ID.
63 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080064 @JsonProperty("flowEntryId")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080065 public FlowEntryId flowEntryId() { return flowEntryId; }
66
67 /**
68 * Set the Flow Entry ID.
69 *
70 * @param flowEntryId the Flow Entry ID to set.
71 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080072 @JsonProperty("flowEntryId")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080073 public void setFlowEntryId(FlowEntryId flowEntryId) {
74 this.flowEntryId = flowEntryId;
75 }
76
77 /**
78 * Get the Flow Entry Match.
79 *
80 * @return the Flow Entry Match.
81 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080082 @JsonProperty("flowEntryMatch")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080083 public FlowEntryMatch flowEntryMatch() { return flowEntryMatch; }
84
85 /**
86 * Set the Flow Entry Match.
87 *
88 * @param flowEntryMatch the Flow Entry Match to set.
89 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080090 @JsonProperty("flowEntryMatch")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080091 public void setFlowEntryMatch(FlowEntryMatch flowEntryMatch) {
92 this.flowEntryMatch = flowEntryMatch;
93 }
94
95 /**
96 * Get the Flow Entry Actions.
97 *
98 * @return the Flow Entry Actions.
99 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -0800100 @JsonProperty("flowEntryActions")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800101 public FlowEntryActions flowEntryActions() { return flowEntryActions; }
102
103 /**
104 * Set the Flow Entry Actions.
105 *
106 * @param flowEntryActions the Flow Entry Actions to set.
107 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -0800108 @JsonProperty("flowEntryActions")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800109 public void setFlowEntryActions(FlowEntryActions flowEntryActions) {
110 this.flowEntryActions = flowEntryActions;
111 }
112
113 /**
114 * Get the Switch DPID.
115 *
116 * @return the Switch DPID.
117 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -0800118 @JsonProperty("dpid")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800119 public Dpid dpid() { return dpid; }
120
121 /**
122 * Set the Switch DPID.
123 *
124 * @param dpid the Switch DPID to set.
125 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -0800126 @JsonProperty("dpid")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800127 public void setDpid(Dpid dpid) {
128 this.dpid = dpid;
129 }
130
131 /**
132 * Get the Switch incoming port.
133 *
134 * @return the Switch incoming port.
135 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -0800136 @JsonProperty("inPort")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800137 public Port inPort() { return inPort; }
138
139 /**
140 * Set the Switch incoming port.
141 *
142 * @param inPort the Switch incoming port to set.
143 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -0800144 @JsonProperty("inPort")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800145 public void setInPort(Port inPort) {
146 this.inPort = inPort;
147 }
148
149 /**
150 * Get the Switch outgoing port.
151 *
152 * @return the Switch outgoing port.
153 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -0800154 @JsonProperty("outPort")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800155 public Port outPort() { return outPort; }
156
157 /**
158 * Set the Switch outgoing port.
159 *
160 * @param outPort the Switch outgoing port to set.
161 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -0800162 @JsonProperty("outPort")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800163 public void setOutPort(Port outPort) {
164 this.outPort = outPort;
165 }
166
167 /**
168 * Get the Flow Entry User state.
169 *
170 * @return the Flow Entry User state.
171 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -0800172 @JsonProperty("flowEntryUserState")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800173 public FlowEntryUserState flowEntryUserState() {
174 return flowEntryUserState;
175 }
176
177 /**
178 * Set the Flow Entry User state.
179 *
180 * @param flowEntryUserState the Flow Entry User state to set.
181 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -0800182 @JsonProperty("flowEntryUserState")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800183 public void setFlowEntryUserState(FlowEntryUserState flowEntryUserState) {
184 this.flowEntryUserState = flowEntryUserState;
185 }
186
187 /**
188 * Get the Flow Entry Switch state.
189 *
190 * The Flow Entry Error state is used if FlowEntrySwitchState is
191 * FE_SWITCH_FAILED.
192 *
193 * @return the Flow Entry Switch state.
194 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -0800195 @JsonProperty("flowEntrySwitchState")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800196 public FlowEntrySwitchState flowEntrySwitchState() {
197 return flowEntrySwitchState;
198 }
199
200 /**
201 * Set the Flow Entry Switch state.
202 *
203 * The Flow Entry Error state is used if FlowEntrySwitchState is
204 * FE_SWITCH_FAILED.
205 *
206 * @param flowEntrySwitchState the Flow Entry Switch state to set.
207 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -0800208 @JsonProperty("flowEntrySwitchState")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800209 public void setFlowEntrySwitchState(FlowEntrySwitchState flowEntrySwitchState) {
210 this.flowEntrySwitchState = flowEntrySwitchState;
211 }
212
213 /**
214 * Get the Flow Entry Error state.
215 *
216 * @return the Flow Entry Error state.
217 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -0800218 @JsonProperty("flowEntryErrorState")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800219 public FlowEntryErrorState flowEntryErrorState() {
220 return flowEntryErrorState;
221 }
222
223 /**
224 * Set the Flow Entry Error state.
225 *
226 * @param flowEntryErrorState the Flow Entry Error state to set.
227 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -0800228 @JsonProperty("flowEntryErrorState")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800229 public void setFlowEntryErrorState(FlowEntryErrorState flowEntryErrorState) {
230 this.flowEntryErrorState = flowEntryErrorState;
231 }
232
233 /**
234 * Convert the flow entry to a string.
235 *
Pavlin Radoslavovad008e02013-02-21 18:42:42 -0800236 * The string has the following form:
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -0800237 * [flowEntryId=XXX flowEntryMatch=XXX flowEntryActions=XXX dpid=XXX
238 * inPort=XXX outPort=XXX flowEntryUserState=XXX flowEntrySwitchState=XXX
239 * flowEntryErrorState=XXX]
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800240 * @return the flow entry as a string.
241 */
242 @Override
243 public String toString() {
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -0800244 String ret = "[flowEntryId=" + this.flowEntryId.toString();
245 ret += " flowEntryMatch=" + this.flowEntryMatch.toString();
246 ret += " flowEntryActions=" + this.flowEntryActions.toString();
247 ret += " dpid=" + this.dpid.toString();
248 ret += " inPort=" + this.inPort.toString();
249 ret += " outPort=" + this.outPort.toString();
250 ret += " flowEntryUserState=" + this.flowEntryUserState;
251 ret += " flowEntrySwitchState=" + this.flowEntrySwitchState;
252 ret += " flowEntryErrorState=" + this.flowEntryErrorState.toString();
Pavlin Radoslavovad008e02013-02-21 18:42:42 -0800253 ret += "]";
254
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800255 return ret;
256 }
257}