blob: efab0cf0d3a10a7d86790a99b0beb83a98f57150 [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;
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -08007import net.floodlightcontroller.util.FlowEntrySwitchState;
8import net.floodlightcontroller.util.FlowEntryUserState;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -08009import net.floodlightcontroller.util.Port;
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080010
11import org.codehaus.jackson.annotate.JsonProperty;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080012
13/**
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080014 * 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 */
19public 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 Radoslavov2013cbb2013-02-26 10:15:18 -080044 @JsonProperty("flowEntryId")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080045 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 Radoslavov2013cbb2013-02-26 10:15:18 -080052 @JsonProperty("flowEntryId")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080053 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 Radoslavov2013cbb2013-02-26 10:15:18 -080062 @JsonProperty("flowEntryMatch")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080063 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 Radoslavov2013cbb2013-02-26 10:15:18 -080070 @JsonProperty("flowEntryMatch")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080071 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 Radoslavov2013cbb2013-02-26 10:15:18 -080080 @JsonProperty("flowEntryActions")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080081 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 Radoslavov2013cbb2013-02-26 10:15:18 -080088 @JsonProperty("flowEntryActions")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080089 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 Radoslavov2013cbb2013-02-26 10:15:18 -080098 @JsonProperty("dpid")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080099 public Dpid dpid() { return dpid; }
100
101 /**
102 * Set the Switch DPID.
103 *
104 * @param dpid the Switch DPID to set.
105 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -0800106 @JsonProperty("dpid")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800107 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 Radoslavov2013cbb2013-02-26 10:15:18 -0800116 @JsonProperty("inPort")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800117 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 Radoslavov2013cbb2013-02-26 10:15:18 -0800124 @JsonProperty("inPort")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800125 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 Radoslavov2013cbb2013-02-26 10:15:18 -0800134 @JsonProperty("outPort")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800135 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 Radoslavov2013cbb2013-02-26 10:15:18 -0800142 @JsonProperty("outPort")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800143 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 Radoslavov2013cbb2013-02-26 10:15:18 -0800152 @JsonProperty("flowEntryUserState")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800153 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 Radoslavov2013cbb2013-02-26 10:15:18 -0800162 @JsonProperty("flowEntryUserState")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800163 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 Radoslavov2013cbb2013-02-26 10:15:18 -0800175 @JsonProperty("flowEntrySwitchState")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800176 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 Radoslavov2013cbb2013-02-26 10:15:18 -0800188 @JsonProperty("flowEntrySwitchState")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800189 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 Radoslavov2013cbb2013-02-26 10:15:18 -0800198 @JsonProperty("flowEntryErrorState")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800199 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 Radoslavov2013cbb2013-02-26 10:15:18 -0800208 @JsonProperty("flowEntryErrorState")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800209 public void setFlowEntryErrorState(FlowEntryErrorState flowEntryErrorState) {
210 this.flowEntryErrorState = flowEntryErrorState;
211 }
212
213 /**
214 * Convert the flow entry to a string.
215 *
Pavlin Radoslavovad008e02013-02-21 18:42:42 -0800216 * The string has the following form:
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -0800217 * [flowEntryId=XXX flowEntryMatch=XXX flowEntryActions=XXX dpid=XXX
218 * inPort=XXX outPort=XXX flowEntryUserState=XXX flowEntrySwitchState=XXX
219 * flowEntryErrorState=XXX]
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800220 * @return the flow entry as a string.
221 */
222 @Override
223 public String toString() {
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -0800224 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 Radoslavovad008e02013-02-21 18:42:42 -0800233 ret += "]";
234
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800235 return ret;
236 }
237}