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