blob: be999731c7fc47cd34ea23b941a0f60a84c62629 [file] [log] [blame]
tom7ef8ff92014-09-17 13:08:06 -07001package org.onlab.onos.of.controller.driver;
2
3import java.util.List;
4
5import org.jboss.netty.channel.Channel;
6import org.onlab.onos.of.controller.OpenFlowSwitch;
7import org.projectfloodlight.openflow.protocol.OFDescStatsReply;
8import org.projectfloodlight.openflow.protocol.OFErrorMsg;
9import org.projectfloodlight.openflow.protocol.OFFeaturesReply;
10import org.projectfloodlight.openflow.protocol.OFMessage;
11import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply;
12import org.projectfloodlight.openflow.protocol.OFVersion;
13
14/**
15 * Represents the driver side of an OpenFlow switch.
16 * This interface should never be exposed to consumers.
17 *
18 */
19public interface OpenFlowSwitchDriver extends OpenFlowSwitch {
20
21 /**
22 * Sets the OpenFlow agent to be used. This method
23 * can only be called once.
24 * @param agent the agent to set.
25 */
26 public void setAgent(OpenFlowAgent agent);
27
28 /**
29 * Sets the Role handler object.
30 * This method can only be called once.
31 * @param roleHandler the roleHandler class
32 */
33 public void setRoleHandler(RoleHandler roleHandler);
34
35 /**
36 * Reasserts this controllers role to the switch.
37 * Useful in cases where the switch no longer agrees
38 * that this controller has the role it claims.
39 */
40 public void reassertRole();
41
42 /**
43 * Handle the situation where the role request triggers an error.
44 * @param error the error to handle.
45 * @return true if handled, false if not.
46 */
47 public boolean handleRoleError(OFErrorMsg error);
48
49 /**
50 * If this driver know of Nicira style role messages, these should
51 * be handled here.
52 * @param m the role message to handle.
53 * @throws SwitchStateException if the message received was
54 * not a nicira role or was malformed.
55 */
56 public void handleNiciraRole(OFMessage m) throws SwitchStateException;
57
58 /**
59 * Handle OF 1.x (where x > 0) role messages.
60 * @param m the role message to handle
61 * @throws SwitchStateException if the message received was
62 * not a nicira role or was malformed.
63 */
64 public void handleRole(OFMessage m) throws SwitchStateException;
65
66 /**
67 * Starts the driver specific handshake process.
68 */
69 public void startDriverHandshake();
70
71 /**
72 * Checks whether the driver specific handshake is complete.
73 * @return true is finished, false if not.
74 */
75 public boolean isDriverHandshakeComplete();
76
77 /**
78 * Process a message during the driver specific handshake.
79 * @param m the message to process.
80 */
81 public void processDriverHandshakeMessage(OFMessage m);
82
83 /**
84 * Announce to the OpenFlow agent that this switch has connected.
85 * @return true if successful, false if duplicate switch.
86 */
87 public boolean connectSwitch();
88
89 /**
90 * Activate this MASTER switch-controller relationship in the OF agent.
91 * @return true is successful, false is switch has not
92 * connected or is unknown to the system.
93 */
94 public boolean activateMasterSwitch();
95
96 /**
97 * Activate this EQUAL switch-controller relationship in the OF agent.
98 * @return true is successful, false is switch has not
99 * connected or is unknown to the system.
100 */
101 public boolean activateEqualSwitch();
102
103 /**
104 * Transition this switch-controller relationship to an EQUAL state.
105 */
106 public void transitionToEqualSwitch();
107
108 /**
109 * Transition this switch-controller relationship to an Master state.
110 */
111 public void transitionToMasterSwitch();
112
113 /**
114 * Remove this switch from the openflow agent.
115 */
116 public void removeConnectedSwitch();
117
118 /**
119 * Sets the ports on this switch.
120 * @param portDescReply the port set and descriptions
121 */
122 public void setPortDescReply(OFPortDescStatsReply portDescReply);
123
124 /**
125 * Sets the features reply for this switch.
126 * @param featuresReply the features to set.
127 */
128 public void setFeaturesReply(OFFeaturesReply featuresReply);
129
130 /**
131 * Sets the switch description.
132 * @param desc the descriptions
133 */
134 public void setSwitchDescription(OFDescStatsReply desc);
135
136 /**
137 * Gets the next transaction id to use.
138 * @return the xid
139 */
140 public int getNextTransactionId();
141
142
143 /**
144 * Does this switch support Nicira Role messages.
145 * @return true if supports, false otherwise.
146 */
147 public Boolean supportNxRole();
148
149 /**
150 * Sets the OF version for this switch.
151 * @param ofV the version to set.
152 */
153 public void setOFVersion(OFVersion ofV);
154
155 /**
156 * Sets this switch has having a full flowtable.
157 * @param full true if full, false otherswise.
158 */
159 public void setTableFull(boolean full);
160
161 /**
162 * Sets the associated Netty channel for this switch.
163 * @param channel the Netty channel
164 */
165 public void setChannel(Channel channel);
166
167 /**
168 * Sets whether the switch is connected.
169 *
170 * @param connected whether the switch is connected
171 */
172 public void setConnected(boolean connected);
173
174 /**
175 * Checks if the switch is still connected.
176 *
177 * @return whether the switch is still connected
178 */
179 public boolean isConnected();
180
181 /**
182 * Writes the message to the output stream
183 * in a driver specific manner.
184 *
185 * @param msg the message to write
186 */
187 public void write(OFMessage msg);
188
189 /**
190 * Writes to the OFMessage list to the output stream
191 * in a driver specific manner.
192 *
193 * @param msgs the messages to be written
194 */
195 public void write(List<OFMessage> msgs);
196
197}